You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/05/29 16:40:10 UTC

git commit: updated refs/heads/fauxton-view-improvements to 0a0bd8c

Updated Branches:
  refs/heads/fauxton-view-improvements c0337e867 -> 0a0bd8c4e


add design doc metadata to view


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0a0bd8c4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0a0bd8c4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0a0bd8c4

Branch: refs/heads/fauxton-view-improvements
Commit: 0a0bd8c4e1b564490b991b8e1a643ed6df0feb16
Parents: c0337e8
Author: Garren Smith <ga...@gmail.com>
Authored: Wed May 29 16:39:24 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed May 29 16:39:24 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/0a0bd8c4/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/0a0bd8c4/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/0a0bd8c4/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/0a0bd8c4/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/0a0bd8c4/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">