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/23 17:48:37 UTC

[1/4] git commit: updated refs/heads/master to 308b993

Updated Branches:
  refs/heads/master 90b6db9f3 -> 308b9937d


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/90666043
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/90666043
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/90666043

Branch: refs/heads/master
Commit: 90666043bae4e744cf3ddd9198fcfe4921e5a392
Parents: 8e297c8
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Oct 16 13:24:09 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Oct 23 17:48:09 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/90666043/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/90666043/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/90666043/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/90666043/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/90666043/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": {


[2/4] git commit: updated refs/heads/master to 308b993

Posted by ga...@apache.org.
started


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

Branch: refs/heads/master
Commit: 8e297c88d400922f86ef33cfb0bec1b18e9d6c40
Parents: 90b6db9
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Oct 15 18:16:05 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Oct 23 17:48:09 2013 +0200

----------------------------------------------------------------------
 .gitignore                                      |  1 +
 src/fauxton/app/addons/compaction/base.js       | 29 +++++++++
 src/fauxton/app/addons/compaction/resources.js  | 21 +++++++
 src/fauxton/app/addons/compaction/routes.js     | 62 ++++++++++++++++++++
 .../app/addons/compaction/templates/layout.html | 27 +++++++++
 src/fauxton/app/addons/compaction/views.js      | 40 +++++++++++++
 src/fauxton/app/api.js                          | 23 ++++++++
 src/fauxton/app/modules/documents/views.js      |  6 +-
 .../app/templates/documents/sidebar.html        |  3 +
 src/fauxton/app/templates/documents/tabs.html   | 21 -------
 src/fauxton/settings.json.default               |  3 +-
 11 files changed, 213 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 95cf2f3..2d6a17b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -101,6 +101,7 @@ src/fauxton/app/addons/*
 !src/fauxton/app/addons/exampleAuth
 !src/fauxton/app/addons/permissions
 !src/fauxton/app/addons/verifyinstall
+!src/fauxton/app/addons/compaction
 src/fauxton/settings.json*
 !src/fauxton/settings.json.default
 src/ibrowse/ibrowse.app

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/addons/compaction/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/base.js b/src/fauxton/app/addons/compaction/base.js
new file mode 100644
index 0000000..8d93016
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/base.js
@@ -0,0 +1,29 @@
+// 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.
+
+define([
+  "app",
+  "api",
+  "addons/compaction/routes"
+],
+
+function(app, FauxtonAPI, Compaction) {
+  Compaction.initialize = function() {
+    FauxtonAPI.registerExtension('docLinks', {
+      title: "Compact & Clean", 
+      url: "compact", 
+      icon: "icon-cogs"
+    });
+  };
+
+  return Compaction;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/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
new file mode 100644
index 0000000..d0180ef
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/resources.js
@@ -0,0 +1,21 @@
+// 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.
+
+define([
+  "app",
+  "api"
+],
+
+function (app, FauxtonAPI) {
+  var Compaction = FauxtonAPI.addon();
+  return Compaction;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/addons/compaction/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/routes.js b/src/fauxton/app/addons/compaction/routes.js
new file mode 100644
index 0000000..e04d386
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/routes.js
@@ -0,0 +1,62 @@
+// 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.
+
+define([
+       "app",
+
+       "api",
+
+       // Modules
+       "addons/compaction/views",
+       "modules/databases/resources"
+],
+
+function(app, FauxtonAPI, Compaction, Databases) {
+
+  var  CompactionRouteObject = FauxtonAPI.RouteObject.extend({
+    layout: "one_pane",
+
+    crumbs: [
+      {"name": "Compact & Clean", "link": "compact"}
+    ],
+
+    routes: {
+      "database/:database/compact": "compaction"
+    },
+
+    initialize: function(route, masterLayout, options) {
+      var databaseName = options[0];
+
+      this.database = this.database || new Databases.Model({id: databaseName});
+    },
+
+    compaction: function () {
+      this.setView('#dashboard-content', new Compaction.Layout({model: this.database}));
+    },
+
+    establish: function () {
+      return this.database.fetch();
+    }
+
+    /*apiUrl: function() {
+      return [this.compactions.url(), this.compactions.documentation];
+    },*/
+
+  });
+
+  Compaction.RouteObjects = [CompactionRouteObject];
+
+  return Compaction;
+
+});
+
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/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
new file mode 100644
index 0000000..56bcbc2
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/templates/layout.html
@@ -0,0 +1,27 @@
+<!--
+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.
+-->
+
+<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>
+

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/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
new file mode 100644
index 0000000..67afd5e
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/views.js
@@ -0,0 +1,40 @@
+// 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.
+
+define([
+       "app",
+
+       "api",
+
+       // Modules
+       "addons/compaction/resources"
+],
+function (app, FauxtonAPI, Compaction) {
+
+  Compaction.Layout = FauxtonAPI.View.extend({
+    template: 'addons/compaction/templates/layout',
+
+    events: {
+      "click compact-db": "compactDB"
+    },
+
+    compactDB: function (event) {
+      event.preventDefault();
+    }
+
+
+  });
+
+
+
+  return Compaction;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index d9f66fe..96d4586 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -452,6 +452,29 @@ function(app, Fauxton) {
 
   });
 
+  var extensions = _.extend({}, Backbone.Events);
+  // Can look at a remove function later.
+  FauxtonAPI.registerExtension = function (name, view) {
+    if (!extensions[name]) {
+      extensions[name] = [];
+    }
+
+    extensions.trigger('add:' + name, view);
+    extensions[name].push(view);
+  };
+
+  FauxtonAPI.getExtensions = function (name) {
+    var views = extensions[name];
+
+    if (!views) {
+      views = [];
+    }
+
+    return views;
+  };
+
+  FauxtonAPI.extensions = extensions;
+
   app.fauxtonAPI = FauxtonAPI;
   return app.fauxtonAPI;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index 283f7b9..eaec296 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -1634,13 +1634,17 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
     },
 
     serialize: function() {
+      var docLinks = FauxtonAPI.getExtensions('docLinks');
+      console.log(docLinks);
       return {
         changes_url: '#' + this.database.url('changes'),
         permissions_url: '#' + this.database.url('app') + '/permissions',
         db_url: '#' + this.database.url('index') + '?limit=100',
         index: [1,2,3],
         view: [1,2],
-        database: this.collection.database
+        database: this.collection.database,
+        database_url: '#' + this.database.url('app'), 
+        docLinks: docLinks
       };
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/templates/documents/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
index eb01942..881309f 100644
--- a/src/fauxton/app/templates/documents/sidebar.html
+++ b/src/fauxton/app/templates/documents/sidebar.html
@@ -25,6 +25,9 @@ the License.
           <li><a class="icon-file" href="<%= db_url %>">Docs</a></li>
           <li><a class="icon-lock" href="<%= permissions_url %>">Permissions</a></li>
           <li><a class="icon-forward" href="<%= changes_url %>">Changes</a></li>
+          <% _.each(docLinks, function (link) { %>
+          <li><a class="<%= link.icon %>" href="<%= database_url + '/' + link.url %>"><%= link.title %></a></li>
+          <% }); %>
         </ul>
       </div>
     </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/8e297c88/src/fauxton/app/templates/documents/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/tabs.html b/src/fauxton/app/templates/documents/tabs.html
index 57e6cb1..f8b0c4b 100644
--- a/src/fauxton/app/templates/documents/tabs.html
+++ b/src/fauxton/app/templates/documents/tabs.html
@@ -14,26 +14,5 @@ the License.
 
 <ul class="nav nav-tabs">
   <li class="active"><a href="<%= db_url %>">Docs</a></li>
-  <!-- TODO::REENABLE
-  <li><a href="#">Permissions</a></li>
-  <li><a href="#">Stats</a></li>
-  -->
   <li id="changes"><a  href="<%= changes_url %>">Changes</a></li>
-  <!-- TODO::REENABLE
-  <div id="search" class="navbar-search span4 nav pull-right input-prepend" style="height:20px;"></div>
-  <!-- TODO: put this styling into less --//>
-  <ul class="nav pull-right" style="margin:5px 10px 0px 10px;">
-    <li>
-      <div class="btn-group">
-        <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
-          <i class="icon icon-cog"></i> Database actions <span class="caret"></span>
-        </a>
-        <ul class="dropdown-menu">
-          <li><a class=""><i class="icon-repeat"></i> Replicate database</a></li>
-          <li><a id="delete-database" class=""><i class="icon-trash"></i> Delete database</a></li>
-        </ul>
-      </div>
-    </li>
-  </ul>
-  -->
 </ul>

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


[3/4] git commit: updated refs/heads/master to 308b993

Posted by ga...@apache.org.
improvements


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

Branch: refs/heads/master
Commit: 4b5841afd9e626b0e04544e3295c8d8dc9ad5500
Parents: 9066604
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Oct 16 15:26:48 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Oct 23 17:48:10 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/compaction/resources.js | 2 +-
 src/fauxton/app/addons/compaction/views.js     | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4b5841af/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 b6fa4bc..e7c97cf 100644
--- a/src/fauxton/app/addons/compaction/resources.js
+++ b/src/fauxton/app/addons/compaction/resources.js
@@ -32,7 +32,7 @@ function (app, FauxtonAPI) {
       contentType: 'application/json',
       type: 'POST'
     });
-  }
+  };
 
   return Compaction;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4b5841af/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 457e5f6..ff6037a 100644
--- a/src/fauxton/app/addons/compaction/views.js
+++ b/src/fauxton/app/addons/compaction/views.js
@@ -14,7 +14,6 @@ define([
        "app",
 
        "api",
-
        // Modules
        "addons/compaction/resources"
 ],
@@ -84,11 +83,7 @@ function (app, FauxtonAPI, Compaction) {
         enableButton('#cleanup-views', 'Run');
       });
     }
-
-
   });
 
-
-
   return Compaction;
 });


[4/4] git commit: updated refs/heads/master to 308b993

Posted by ga...@apache.org.
Finish view compaction


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

Branch: refs/heads/master
Commit: 308b9937de3a1a46705e2be3ea31828722b1db1b
Parents: 4b5841a
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Oct 22 17:17:58 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Oct 23 17:48:10 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/compaction/base.js       |  2 +
 src/fauxton/app/addons/compaction/resources.js  | 10 ++++
 src/fauxton/app/addons/compaction/routes.js     | 10 ++--
 .../compaction/templates/compact_view.html      | 14 +++++
 .../app/addons/compaction/templates/layout.html |  8 ---
 src/fauxton/app/addons/compaction/views.js      | 57 ++++++++++++++++++--
 src/fauxton/app/modules/documents/views.js      | 22 ++++++--
 .../templates/documents/advanced_options.html   |  2 +-
 src/fauxton/extensions.md                       | 17 ++++++
 9 files changed, 124 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/app/addons/compaction/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/base.js b/src/fauxton/app/addons/compaction/base.js
index 8d93016..de0f124 100644
--- a/src/fauxton/app/addons/compaction/base.js
+++ b/src/fauxton/app/addons/compaction/base.js
@@ -23,6 +23,8 @@ function(app, FauxtonAPI, Compaction) {
       url: "compact", 
       icon: "icon-cogs"
     });
+
+    FauxtonAPI.registerExtension('advancedOptions:ViewButton', new Compaction.CompactView({}));
   };
 
   return Compaction;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/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 e7c97cf..6633677 100644
--- a/src/fauxton/app/addons/compaction/resources.js
+++ b/src/fauxton/app/addons/compaction/resources.js
@@ -34,5 +34,15 @@ function (app, FauxtonAPI) {
     });
   };
 
+
+  Compaction.compactView = function (db, designDoc) {
+    // /some_database/_compact/designname
+    return $.ajax({
+      url: db.url() + '/_compact/' + designDoc.replace('_design/','') ,
+      contentType: 'application/json',
+      type: 'POST'
+    });
+  };
+
   return Compaction;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/app/addons/compaction/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/routes.js b/src/fauxton/app/addons/compaction/routes.js
index e04d386..b7a2ee3 100644
--- a/src/fauxton/app/addons/compaction/routes.js
+++ b/src/fauxton/app/addons/compaction/routes.js
@@ -25,9 +25,13 @@ function(app, FauxtonAPI, Compaction, Databases) {
   var  CompactionRouteObject = FauxtonAPI.RouteObject.extend({
     layout: "one_pane",
 
-    crumbs: [
-      {"name": "Compact & Clean", "link": "compact"}
-    ],
+    crumbs: function () {
+      return [
+        {"name": "Databases", "link": "/_all_dbs"},
+        {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
+        {"name": "Compact & Clean", "link": "compact"}
+      ];
+    },
 
     routes: {
       "database/:database/compact": "compaction"

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/app/addons/compaction/templates/compact_view.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/compaction/templates/compact_view.html b/src/fauxton/app/addons/compaction/templates/compact_view.html
new file mode 100644
index 0000000..8a0b7ec
--- /dev/null
+++ b/src/fauxton/app/addons/compaction/templates/compact_view.html
@@ -0,0 +1,14 @@
+<!--
+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.
+-->
+Compact View

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/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 08a2078..5125892 100644
--- a/src/fauxton/app/addons/compaction/templates/layout.html
+++ b/src/fauxton/app/addons/compaction/templates/layout.html
@@ -21,14 +21,6 @@ the License.
 
 <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>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/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 ff6037a..06a1300 100644
--- a/src/fauxton/app/addons/compaction/views.js
+++ b/src/fauxton/app/addons/compaction/views.js
@@ -49,7 +49,7 @@ function (app, FauxtonAPI, Compaction) {
       Compaction.compactDB(this.model).then(function () {
         FauxtonAPI.addNotification({
           type: 'success',
-          msg: 'Database compaction has started.'
+          msg: 'Database compaction has started. Visit <a href="#activetasks">Active Tasks</a> to view the compaction progress.',
         });
       }, function (xhr, error, reason) {
         console.log(arguments);
@@ -71,10 +71,9 @@ function (app, FauxtonAPI, Compaction) {
       Compaction.cleanupViews(this.model).then(function () {
         FauxtonAPI.addNotification({
           type: 'success',
-          msg: 'View cleanup has started.'
+          msg: 'View cleanup has started. Visit <a href="#activetasks">Active Tasks</a> to view progress.'
         });
       }, function (xhr, error, reason) {
-        console.log(arguments);
         FauxtonAPI.addNotification({
           type: 'error',
           msg: 'Error: ' + JSON.parse(xhr.responseText).reason
@@ -85,5 +84,57 @@ function (app, FauxtonAPI, Compaction) {
     }
   });
 
+  Compaction.CompactView = FauxtonAPI.View.extend({
+    template: 'addons/compaction/templates/compact_view',
+    className: 'btn btn-info btn-large pull-right',
+    tagName: 'button',
+
+    initialize: function () {
+      _.bindAll(this);
+    },
+
+    events: {
+      "click": "compact"
+    },
+
+    disableButton: function () {
+      this.$el.attr('disabled', 'disabled').text('Compacting...');
+    },
+
+    enableButton: function () {
+      this.$el.removeAttr('disabled').text('Compact View');
+    },
+
+
+    update: function (database, designDoc, viewName) {
+      this.database = database;
+      this.designDoc = designDoc;
+      this.viewName = viewName;
+    },
+
+    compact: function (event) {
+      event.preventDefault();
+      var enableButton = this.enableButton;
+
+      this.disableButton();
+
+      Compaction.compactView(this.database, this.designDoc).then(function () {
+        FauxtonAPI.addNotification({
+          type: 'success',
+          msg: 'View compaction has started. Visit <a href="#activetasks">Active Tasks</a> to view progress.'
+        });
+      }, function (xhr, error, reason) {
+        FauxtonAPI.addNotification({
+          type: 'error',
+          msg: 'Error: ' + JSON.parse(xhr.responseText).reason
+        });
+      }).always(function () {
+        enableButton();
+      });
+
+    }
+
+  });
+
   return Compaction;
 });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index eaec296..cf5dd35 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -479,7 +479,8 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
         updateViewFn: this.updateView,
         previewFn: this.previewView,
         hasReduce: false,
-        showPreview: false
+        showPreview: false,
+        database: this.database
       }));
 
       this.$('#query').hide();
@@ -970,6 +971,9 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
     className: "advanced-options well",
 
     initialize: function (options) {
+      this.database = options.database;
+      this.ddocName = options.ddocName;
+      this.viewName = options.viewName;
       this.updateViewFn = options.updateViewFn;
       this.previewFn = options.previewFn;
       this.hadReduce = options.hasReduce || true;
@@ -994,6 +998,16 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
       "click button.preview": "previewView"
     },
 
+    beforeRender: function () {
+      if (this.viewName && this.ddocName) {
+        var buttonViews = FauxtonAPI.getExtensions('advancedOptions:ViewButton');
+        _.each(buttonViews, function (view) {
+          this.insertView('#button-options', view);
+          view.update(this.database, this.ddocName, this.viewName);
+        }, this);
+      }
+    },
+
     queryParams: function () {
       var $form = this.$(".view-query-update");
       // Ignore params without a value
@@ -1496,7 +1510,10 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
 
       this.advancedOptions = this.insertView('#query', new Views.AdvancedOptions({
         updateViewFn: this.updateView,
-        previewFn: this.previewView
+        previewFn: this.previewView,
+        database: this.database,
+        viewName: this.viewName,
+        ddocName: this.model.id
       }));
     },
 
@@ -1635,7 +1652,6 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
 
     serialize: function() {
       var docLinks = FauxtonAPI.getExtensions('docLinks');
-      console.log(docLinks);
       return {
         changes_url: '#' + this.database.url('changes'),
         permissions_url: '#' + this.database.url('app') + '/permissions',

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/app/templates/documents/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options.html b/src/fauxton/app/templates/documents/advanced_options.html
index aee2f65..c0bf44a 100644
--- a/src/fauxton/app/templates/documents/advanced_options.html
+++ b/src/fauxton/app/templates/documents/advanced_options.html
@@ -81,7 +81,7 @@ the License.
   </div>
   <div class="controls-group">
     <div class="row-fluid">
-      <div class="controls controls-row">
+      <div id="button-options" class="controls controls-row">
         <button type="submit" class="btn btn-primary btn-large">Query</button>
         <% if (showPreview) { %>
         <button class="btn btn-info btn-large preview">Preview</button>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/308b9937/src/fauxton/extensions.md
----------------------------------------------------------------------
diff --git a/src/fauxton/extensions.md b/src/fauxton/extensions.md
new file mode 100644
index 0000000..13fcf8d
--- /dev/null
+++ b/src/fauxton/extensions.md
@@ -0,0 +1,17 @@
+#Extensions
+
+Extensions allow Fauxton views to be have extra functionality.
+
+A module registers an extension by
+
+    FauxtonAPI.registerExtension('extensionName', myObjectToRegister);
+
+Any other module wanting to use that extension can then get 
+all objects registered for an extension by:
+
+    var extensions = FauxtonAPI.getExtensions('extensionName');
+    // extensions will always be an array
+
+The module can then use those extensions to extend its functionality.
+An example of extensions in the compaction module (app/addons/compaction/base.js) 
+and in documents module (app/modules/documents/views line 1003)