diff options
Diffstat (limited to 'src/fauxton/app/addons/compaction/views.js')
-rw-r--r-- | src/fauxton/app/addons/compaction/views.js | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/fauxton/app/addons/compaction/views.js b/src/fauxton/app/addons/compaction/views.js index ff6037add..06a13003c 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; }); |