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 7BE631018C for ; Wed, 12 Feb 2014 06:24:43 +0000 (UTC) Received: (qmail 4026 invoked by uid 500); 12 Feb 2014 06:21:19 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 3322 invoked by uid 500); 12 Feb 2014 06:20:59 -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 1526 invoked by uid 99); 12 Feb 2014 06:20:01 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Feb 2014 06:20:01 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1440E5542A; Wed, 12 Feb 2014 06:20:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Wed, 12 Feb 2014 06:20:42 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [48/52] [abbrv] fauxton commit: updated refs/heads/import-master to d11b90b Add more caching locations Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/4b5735c7 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/4b5735c7 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/4b5735c7 Branch: refs/heads/import-master Commit: 4b5735c7d4b456acbe457d3c7da675b8a0be0d20 Parents: f111540 Author: Garren Smith Authored: Wed Feb 5 19:23:12 2014 +0200 Committer: Garren Smith Committed: Wed Feb 5 19:23:12 2014 +0200 ---------------------------------------------------------------------- app/addons/databases/resources.js | 5 +++++ app/addons/databases/routes.js | 2 +- app/addons/databases/views.js | 2 +- app/addons/documents/views.js | 21 +++------------------ app/core/base.js | 21 ++++++++++++++++++--- app/core/couchdbSession.js | 11 +++++++++-- 6 files changed, 37 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/addons/databases/resources.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/resources.js b/app/addons/databases/resources.js index 5fa931b..ea1aed2 100644 --- a/app/addons/databases/resources.js +++ b/app/addons/databases/resources.js @@ -171,6 +171,11 @@ function(app, FauxtonAPI, Documents) { documentation: function(){ return "all_dbs"; }, + + cache: { + expires: 60 + }, + url: function(context) { if (context === "apiurl") { return window.location.origin + "/_all_dbs"; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/addons/databases/routes.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/routes.js b/app/addons/databases/routes.js index c413018..131abf9 100644 --- a/app/addons/databases/routes.js +++ b/app/addons/databases/routes.js @@ -59,7 +59,7 @@ function(app, FauxtonAPI, Databases, Views) { }, establish: function() { - return [this.databases.fetch()]; + return [this.databases.fetchOnce()]; } }); http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/addons/databases/views.js ---------------------------------------------------------------------- diff --git a/app/addons/databases/views.js b/app/addons/databases/views.js index afe2d1c..7f23d65 100644 --- a/app/addons/databases/views.js +++ b/app/addons/databases/views.js @@ -61,7 +61,7 @@ function(app, Components, FauxtonAPI, Databases) { var deferred = FauxtonAPI.Deferred(); FauxtonAPI.when(currentDBs.map(function(database) { - return database.status.fetch(); + return database.status.fetchOnce(); })).always(function(resp) { //make this always so that even if a user is not allowed access to a database //they will still see a list of all databases http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/addons/documents/views.js ---------------------------------------------------------------------- diff --git a/app/addons/documents/views.js b/app/addons/documents/views.js index 5476203..13cbacb 100644 --- a/app/addons/documents/views.js +++ b/app/addons/documents/views.js @@ -1804,30 +1804,15 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum template: "addons/documents/templates/changes", initialize: function () { - var that = this; - this.listenTo( this.model.changes, 'change', function () { - console.log('render on change'); - that.render(); - }); - this.listenTo( this.model.changes, 'cachesync', function () { - console.log('render on cachesync'); - that.render(); - }); + this.listenTo( this.model.changes, 'sync', this.render); + this.listenTo( this.model.changes, 'cachesync', this.render); }, establish: function() { - return [ this.model.changes.fetchOnce({prefill: true, - success: function () { - console.log('hi ajax success'); - }, - prefillSuccess: function () { - console.log('hi prefill success'); - } - })]; + return [ this.model.changes.fetchOnce({prefill: true})]; }, serialize: function () { - console.log('ss'); return { changes: this.model.changes.toJSON(), database: this.model http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/core/base.js ---------------------------------------------------------------------- diff --git a/app/core/base.js b/app/core/base.js index 6fe3261..24b89cf 100644 --- a/app/core/base.js +++ b/app/core/base.js @@ -17,7 +17,6 @@ define([ ], function(Backbone, LayoutManager, BackboneCache) { - console.log(BackboneCache); var FauxtonAPI = { //add default objects router: { @@ -81,8 +80,24 @@ function(Backbone, LayoutManager, BackboneCache) { var caching = { fetchOnce: function (opts) { var options = _.defaults(opts || {}, this.cache, {cache: true}); - console.log('opts', options); - return this.fetch(options); + + if (opts && !opts.cache) { + delete options.cache; + } + + if (!options.prefill) { + return this.fetch(options); + } + + //With Prefill, the Caching with resolve with whatever is in the cache for that model/collection + //and at the sametime it will fetch from the server the latest. + var promise = FauxtonAPI.Deferred(), + fetchPromise = this.fetch(options); + + fetchPromise.progress(promise.resolveWith); // Fires when the cache hit happens + fetchPromise.then(promise.resolveWith); // Fires after the AJAX call + + return promise; } }; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/4b5735c7/app/core/couchdbSession.js ---------------------------------------------------------------------- diff --git a/app/core/couchdbSession.js b/app/core/couchdbSession.js index 93bfd8a..b70ddf3 100644 --- a/app/core/couchdbSession.js +++ b/app/core/couchdbSession.js @@ -29,9 +29,16 @@ function (FauxtonAPI) { fetchUser: function (opt) { var that = this, - currentUser = this.user(); + options = opt || {}, + currentUser = this.user(), + fetch = this.fetchOnce; - return this.fetchOnce(opt).then(function () { + if (options.forceFetch) { + fetch = this.fetch; + Backbone.fetchCache.clearItem(_.result(this.url)); + } + + return this.fetch(opt).then(function () { var user = that.user(); // Notify anyone listening on these events that either a user has changed