summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2013-10-15 18:16:05 +0200
committerGarren Smith <garren.smith@gmail.com>2013-10-23 17:48:09 +0200
commit8e297c88d400922f86ef33cfb0bec1b18e9d6c40 (patch)
tree2b59b08a2b0d5595bae4d41504f7d81ecda7a7ff
parent90b6db9f3a91929065a807dd377d0f01df0b47e9 (diff)
downloadcouchdb-8e297c88d400922f86ef33cfb0bec1b18e9d6c40.tar.gz
started
-rw-r--r--.gitignore1
-rw-r--r--src/fauxton/app/addons/compaction/base.js29
-rw-r--r--src/fauxton/app/addons/compaction/resources.js21
-rw-r--r--src/fauxton/app/addons/compaction/routes.js62
-rw-r--r--src/fauxton/app/addons/compaction/templates/layout.html27
-rw-r--r--src/fauxton/app/addons/compaction/views.js40
-rw-r--r--src/fauxton/app/api.js23
-rw-r--r--src/fauxton/app/modules/documents/views.js6
-rw-r--r--src/fauxton/app/templates/documents/sidebar.html3
-rw-r--r--src/fauxton/app/templates/documents/tabs.html21
-rw-r--r--src/fauxton/settings.json.default3
11 files changed, 213 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 95cf2f3ec..2d6a17bc1 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
diff --git a/src/fauxton/app/addons/compaction/base.js b/src/fauxton/app/addons/compaction/base.js
new file mode 100644
index 000000000..8d930166d
--- /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;
+});
diff --git a/src/fauxton/app/addons/compaction/resources.js b/src/fauxton/app/addons/compaction/resources.js
new file mode 100644
index 000000000..d0180eff3
--- /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;
+});
diff --git a/src/fauxton/app/addons/compaction/routes.js b/src/fauxton/app/addons/compaction/routes.js
new file mode 100644
index 000000000..e04d38652
--- /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;
+
+});
+
+
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 000000000..56bcbc23c
--- /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>
+
diff --git a/src/fauxton/app/addons/compaction/views.js b/src/fauxton/app/addons/compaction/views.js
new file mode 100644
index 000000000..67afd5e87
--- /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;
+});
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index d9f66fe76..96d458608 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;
});
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index 283f7b9f2..eaec29673 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
};
},
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
index eb01942db..881309f94 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>
diff --git a/src/fauxton/app/templates/documents/tabs.html b/src/fauxton/app/templates/documents/tabs.html
index 57e6cb180..f8b0c4b44 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>
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index ce45e267a..54cc0ce10 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": {