Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D2831089F for ; Mon, 22 Jul 2013 10:25:35 +0000 (UTC) Received: (qmail 11679 invoked by uid 500); 22 Jul 2013 10:25:25 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 11259 invoked by uid 500); 22 Jul 2013 10:25:20 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 10269 invoked by uid 99); 22 Jul 2013 10:25:18 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jul 2013 10:25:18 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7089B8B06B5; Mon, 22 Jul 2013 10:25:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org Date: Mon, 22 Jul 2013 10:25:26 -0000 Message-Id: <652c019fe95d4519bf20d5a09a05398f@git.apache.org> In-Reply-To: <10f5b68774524227a2f788b7e382a844@git.apache.org> References: <10f5b68774524227a2f788b7e382a844@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/50] [abbrv] git commit: updated refs/heads/1684-feature-db-updates to ea07223 Add design doc metadata to view Fixes issue #1816 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9cace040 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9cace040 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9cace040 Branch: refs/heads/1684-feature-db-updates Commit: 9cace040dbf48b4b366e2118b9e2078d8d0ee1db Parents: 90e4da6 Author: Garren Smith Authored: Wed May 29 16:39:24 2013 +0200 Committer: Garren Smith Committed: Tue Jun 4 15:46:38 2013 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/logs/resources.js | 8 ++-- src/fauxton/app/modules/documents/resources.js | 27 +++++++++++- src/fauxton/app/modules/documents/views.js | 44 +++++++++++++++++++- .../app/templates/documents/ddoc_info.html | 8 ++++ .../app/templates/documents/view_editor.html | 1 + 5 files changed, 82 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/9cace040/src/fauxton/app/addons/logs/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js index bf7f657..955b3ec 100644 --- a/src/fauxton/app/addons/logs/resources.js +++ b/src/fauxton/app/addons/logs/resources.js @@ -158,14 +158,14 @@ function (app, FauxtonAPI, Backbone) { }, startRefreshInterval: function () { - var that = this; + var collection = this.collection; // Interval already set - if (that.intervalId) { return ; } + if (this.intervalId) { return ; } that.intervalId = setInterval(function () { - that.collection.fetch(); - }, that.refreshTime); + collection.fetch(); + }, this.refreshTime); }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/9cace040/src/fauxton/app/modules/documents/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js index e313378..7bfee3d 100644 --- a/src/fauxton/app/modules/documents/resources.js +++ b/src/fauxton/app/modules/documents/resources.js @@ -164,6 +164,31 @@ function(app, FauxtonAPI) { } }); + Documents.DdocInfo = Backbone.Model.extend({ + idAttribute: "_id", + + initialize: function (_attrs, options) { + this.database = options.database; + }, + + url: function(context) { + if (context === "app") { + return this.database.url("app") + "/" + this.safeID() + '/_info'; + } else { + return app.host + "/" + this.database.id + "/" + this.id + '/_info'; + } + }, + + // Need this to work around backbone router thinking _design/foo + // is a separate route. Alternatively, maybe these should be + // treated separately. For instance, we could default into the + // json editor for docs, or into a ddoc specific page. + safeID: function() { + return this.id.replace('/', '%2F'); + } + + }); + Documents.ViewRow = Backbone.Model.extend({ docType: function() { if (!this.id) return "reduction"; @@ -330,7 +355,6 @@ function(app, FauxtonAPI) { }, totalRows: function() { - console.log('rows'); console.log(this); return this.viewMeta.total_rows || "unknown"; }, @@ -349,5 +373,6 @@ function(app, FauxtonAPI) { }); + return Documents; }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/9cace040/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 f5cd882..af85134 100644 --- a/src/fauxton/app/modules/documents/views.js +++ b/src/fauxton/app/modules/documents/views.js @@ -545,9 +545,14 @@ function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) { } else { this.ddocID = options.ddocInfo.id; this.viewName = options.viewName; + this.ddocInfo = new Documents.DdocInfo({_id: this.ddocID},{database: this.database}); } }, + establish: function () { + return this.ddocInfo.fetch(); + }, + updateDesignDoc: function () { if (this.$('#ddoc :selected').prop('id') === 'new-doc') { @@ -915,6 +920,7 @@ function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) { } else { this.model = this.ddocs.get(this.ddocID).dDocModel(); this.reduceFunStr = this.model.viewHasReduce(this.viewName); + this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo })); } }, @@ -1081,7 +1087,6 @@ function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) { }, serialize: function () { - console.log('c', this.model.changes.toJSON()); return { changes: this.model.changes.toJSON(), database: this.model @@ -1091,8 +1096,45 @@ function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) { afterRender: function(){ prettyPrint(); } + }); + + Views.DdocInfo = FauxtonAPI.View.extend({ + template: "templates/documents/ddoc_info", + + initialize: function (options) { + this.refreshTime = options.refreshTime || 5000; + this.listenTo(this.model, 'change', this.render); + }, + + serialize: function () { + return { + view_index: this.model.get('view_index') + }; + }, + + afterRender: function () { + this.startRefreshInterval(); + }, + startRefreshInterval: function () { + var model = this.model; + // Interval already set + if (this.intervalId) { return ; } + + this.intervalId = setInterval(function () { + console.log('refreshing'); + model.fetch(); + }, this.refreshTime); + }, + + stopRefreshInterval: function () { + clearInterval(this.intervalId); + }, + + cleanup: function () { + this.stopRefreshInterval(); + } }); Documents.Views = Views; http://git-wip-us.apache.org/repos/asf/couchdb/blob/9cace040/src/fauxton/app/templates/documents/ddoc_info.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/templates/documents/ddoc_info.html b/src/fauxton/app/templates/documents/ddoc_info.html new file mode 100644 index 0000000..18bf4d8 --- /dev/null +++ b/src/fauxton/app/templates/documents/ddoc_info.html @@ -0,0 +1,8 @@ +
+

Design Doc MetaData

+
    + <% _.each(view_index, function (val, key) { %> +
  • <%= key %> : <%= val %>
  • + <% }); %> +
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/9cace040/src/fauxton/app/templates/documents/view_editor.html ---------------------------------------------------------------------- diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html index a34ff0d..32f1d14 100644 --- a/src/fauxton/app/templates/documents/view_editor.html +++ b/src/fauxton/app/templates/documents/view_editor.html @@ -14,6 +14,7 @@ the License.
+