diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-10-16 13:24:09 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-10-23 17:48:09 +0200 |
commit | 90666043bae4e744cf3ddd9198fcfe4921e5a392 (patch) | |
tree | d8b1daa781ac6ebe1f451ace92627e11cf98215d | |
parent | 8e297c88d400922f86ef33cfb0bec1b18e9d6c40 (diff) | |
download | couchdb-90666043bae4e744cf3ddd9198fcfe4921e5a392.tar.gz |
compact and clean up working
-rw-r--r-- | src/fauxton/app/addons/compaction/assets/less/compaction.less | 8 | ||||
-rw-r--r-- | src/fauxton/app/addons/compaction/resources.js | 17 | ||||
-rw-r--r-- | src/fauxton/app/addons/compaction/templates/layout.html | 33 | ||||
-rw-r--r-- | src/fauxton/app/addons/compaction/views.js | 56 | ||||
-rw-r--r-- | src/fauxton/settings.json.default | 4 |
5 files changed, 103 insertions, 15 deletions
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 000000000..c197d9a16 --- /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; + +} diff --git a/src/fauxton/app/addons/compaction/resources.js b/src/fauxton/app/addons/compaction/resources.js index d0180eff3..b6fa4bc84 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; }); diff --git a/src/fauxton/app/addons/compaction/templates/layout.html b/src/fauxton/app/addons/compaction/templates/layout.html index 56bcbc23c..08a2078cd 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> diff --git a/src/fauxton/app/addons/compaction/views.js b/src/fauxton/app/addons/compaction/views.js index 67afd5e87..457e5f6d6 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'); + }); } diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default index 54cc0ce10..1b6891170 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": { |