couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [1/4] git commit: updated refs/heads/master to df23be9
Date Tue, 04 Jun 2013 13:46:57 GMT
Updated Branches:
  refs/heads/master eb364ff3a -> df23be933


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/master
Commit: 9cace040dbf48b4b366e2118b9e2078d8d0ee1db
Parents: 90e4da6
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed May 29 16:39:24 2013 +0200
Committer: Garren Smith <garren.smith@gmail.com>
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 ++++++++++++++-
 src/fauxton/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 @@
+<div class="well" >
+  <h2> Design Doc MetaData </h2>
+  <ul style="list-style-type: none;">
+  <% _.each(view_index, function (val, key) { %>
+    <li><strong> <%= key %></strong> : <%= val %>  </li>
+  <% }); %>
+  </ul>
+</div>

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.
 <div class="row">
   <div class="all-docs-list errors-container"></div>
   <div id="edit-index-container">
+    <div id="ddoc-info"> </div>
 
     <div class="accordion" id="edit-index-accordion">
       <div class="accordion-group">


Mime
View raw message