Fauxton: highlight databases with more deleted docs than existing Fixes COUCHDB-2110
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/d88bae72 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/d88bae72 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/d88bae72 Branch: refs/heads/import-master Commit: d88bae7229291e2ba0fd335f6ffa6cb0bba04bb0 Parents: 7205e48 Author: Robert Kowalski <r...@kowalski.gd> Authored: Fri Mar 14 20:45:31 2014 +0100 Committer: Robert Kowalski <r...@kowalski.gd> Committed: Fri Mar 14 20:45:43 2014 +0100 ---------------------------------------------------------------------- app/addons/databases/resources.js | 8 +++++ app/addons/databases/templates/item.html | 8 ++++- app/addons/databases/tests/resourcesSpec.js | 39 ++++++++++++++++++++++++ app/addons/databases/views.js | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d88bae72/app/addons/databases/resources.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/resources.js b/app/addons/databases/resources.js index 80cd533..f8aab96 100644 --- a/app/addons/databases/resources.js +++ b/app/addons/databases/resources.js @@ -123,6 +123,14 @@ function(app, FauxtonAPI, Documents) { return this.get("doc_count"); }, + numDeletedDocs: function() { + return this.get("doc_del_count"); + }, + + isGraveYard: function() { + return this.numDeletedDocs() > this.numDocs(); + }, + updateSeq: function(full) { var updateSeq = this.get("update_seq"); if (full || (typeof(updateSeq) === 'number')) { http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d88bae72/app/addons/databases/templates/item.html ---------------------------------------------------------------------- diff --git a/app/addons/databases/templates/item.html b/app/addons/databases/templates/item.html index 549f421..304ab78 100644 --- a/app/addons/databases/templates/item.html +++ b/app/addons/databases/templates/item.html @@ -16,7 +16,13 @@ the License. <a href="#/database/<%=encoded%>/_all_docs"><%= database.get("name") %></a> </td> <td><%= database.status.humanSize() %></td> -<td><%= database.status.numDocs() %></td> +<td> + <%= database.status.numDocs() %> + <% if (database.status.isGraveYard()) { %> + <i class="js-db-graveyard icon icon-exclamation-sign" data-toggle="tooltip" + title="This database has just <%= database.status.numDocs() %> docs and <%= database.status.numDeletedDocs() %> deleted docs"></i> + <% } %> +</td> <td><%= database.status.updateSeq() %></td> <td> <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d88bae72/app/addons/databases/tests/resourcesSpec.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/tests/resourcesSpec.js b/app/addons/databases/tests/resourcesSpec.js new file mode 100644 index 0000000..8e3fee4 --- /dev/null +++ b/app/addons/databases/tests/resourcesSpec.js @@ -0,0 +1,39 @@ +// 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([ + 'api', + 'addons/databases/resources', + 'addons/databases/views', + 'testUtils' +], function (FauxtonAPI, Resources, Views, testUtils) { + var assert = testUtils.assert, + ViewSandbox = testUtils.ViewSandbox; + + describe("Databases: List", function () { + + describe("List items", function () { + + it("detects graveyards", function () { + var modelWithGraveYard = new Resources.Status({ + doc_count: 5, + doc_del_count: 6 + }); + var modelWithoutGraveYard = new Resources.Status({ + doc_count: 6, + doc_del_count: 5 + }); + assert.ok(modelWithGraveYard.isGraveYard()); + assert.ok(!modelWithoutGraveYard.isGraveYard()); + }); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d88bae72/app/addons/databases/views.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/views.js b/app/addons/databases/views.js index ef52b2f..d632486 100644 --- a/app/addons/databases/views.js +++ b/app/addons/databases/views.js @@ -137,6 +137,7 @@ function(app, Components, FauxtonAPI, Databases) { } }); this.dbSearchTypeahead.render(); + this.$el.find(".js-db-graveyard").tooltip(); }, selectAll: function(evt){