You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2013/12/23 17:03:10 UTC

[4/4] git commit: updated refs/heads/ENCODE-EVERYTHING to f3c9b4c

Fix API urls
Fix data size


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

Branch: refs/heads/ENCODE-EVERYTHING
Commit: f3c9b4c70aceea221e3c671634ebfb0428e67371
Parents: 8db54be
Author: suelockwood <de...@apache.org>
Authored: Mon Dec 23 11:01:34 2013 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Dec 23 11:02:59 2013 -0500

----------------------------------------------------------------------
 src/fauxton/app/addons/activetasks/resources.js |  8 +++++--
 src/fauxton/app/addons/activetasks/routes.js    |  2 +-
 src/fauxton/app/modules/databases/resources.js  | 25 ++++++++++++++++----
 src/fauxton/app/modules/databases/routes.js     |  2 +-
 src/fauxton/app/modules/documents/resources.js  | 11 ++++++++-
 src/fauxton/app/modules/documents/routes.js     |  8 +++----
 6 files changed, 42 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/src/fauxton/app/addons/activetasks/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js
index 4625871..ca732fb 100644
--- a/src/fauxton/app/addons/activetasks/resources.js
+++ b/src/fauxton/app/addons/activetasks/resources.js
@@ -38,8 +38,12 @@ function (app, backbone, Fauxton) {
       "view_compaction": "View Compaction"
     },
     documentation: "_active_tasks",
-    url: function () {
-      return app.host + '/_active_tasks';
+    url: function (context) {
+      if (context === "apiurl"){
+        return window.location.origin + '/_active_tasks';
+      } else {
+        return app.host + '/_active_tasks';
+      }
     },
     fetch: function (options) {
      var fetchoptions = options || {};

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/src/fauxton/app/addons/activetasks/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/routes.js b/src/fauxton/app/addons/activetasks/routes.js
index e0454b7..89bcfcc 100644
--- a/src/fauxton/app/addons/activetasks/routes.js
+++ b/src/fauxton/app/addons/activetasks/routes.js
@@ -30,7 +30,7 @@ function (app, FauxtonAPI, Activetasks, Views) {
     {"name": "Active tasks", "link": "activetasks"}
     ],
     apiUrl: function(){
-      return [this.newtasks.url(), this.newtasks.documentation];
+      return [this.newtasks.url("apiurl"), this.newtasks.documentation];
     }, 
 
     roles: ["_admin"],

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/src/fauxton/app/modules/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
index a01c9ce..a716ea1 100644
--- a/src/fauxton/app/modules/databases/resources.js
+++ b/src/fauxton/app/modules/databases/resources.js
@@ -54,8 +54,12 @@ function(app, FauxtonAPI, Documents) {
         return "/database/" + this.safeID() + "/_all_docs";
       } else if (context === "web-index") {
         return "#/database/"+ this.safeID() + "/_all_docs?limit=" + Databases.DocLimit;
+      } else if (context === "apiurl") { 
+        return window.location.origin + "/database/" + this.safeID() + "/_all_docs";
       } else if (context === "changes") {
         return "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
+      } else if (context === "changes-apiurl") { 
+        return window.location.origin + "/database/" + this.safeID() + "/_changes?descending=true&limit=100&include_docs=true";
       } else if (context === "app") {
         return "/database/" + this.safeID();
       } else {
@@ -87,13 +91,17 @@ function(app, FauxtonAPI, Documents) {
     documentation: function(){
       return "changes";
     },
-    url: function () {
+    url: function (context) {
       var query = "";
       if (this.params) {
         query = "?" + $.param(this.params);
       }
+      if (context === "apiurl") { 
+        return window.location.origin + '/' + this.database.safeID() + '/_changes' + query;
+      } else {
 
       return app.host + '/' + this.database.safeID() + '/_changes' + query;
+      }
     },
 
     parse: function (resp) {
@@ -130,7 +138,7 @@ function(app, FauxtonAPI, Documents) {
       // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
       var i = -1;
       var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
-      var fileSizeInBytes = this.diskSize();
+      var fileSizeInBytes = this.dataSize();
 
       if (!fileSizeInBytes) {
         return 0;
@@ -143,9 +151,12 @@ function(app, FauxtonAPI, Documents) {
 
       return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
     },
-
     diskSize: function () {
       return this.get("disk_size");
+    },
+
+    dataSize: function () {
+      return this.get("other").data_size;
     }
   });
 
@@ -155,8 +166,12 @@ function(app, FauxtonAPI, Documents) {
     documentation: function(){
       return "all_dbs";
     },
-    url: function() {
-      return app.host + "/_all_dbs";
+    url: function(context) {
+      if (context === "apiurl") { 
+        return window.location.origin + "/_all_dbs";
+      } else {
+        return app.host + "/_all_dbs";
+      }
     },
 
     parse: function(resp) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/src/fauxton/app/modules/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
index e63c3a7..ca3d640 100644
--- a/src/fauxton/app/modules/databases/routes.js
+++ b/src/fauxton/app/modules/databases/routes.js
@@ -37,7 +37,7 @@ function(app, FauxtonAPI, Databases, Views) {
     },
 
     apiUrl: function() {
-      return [this.databases.url(), this.databases.documentation()];
+      return [this.databases.url("apiurl"), this.databases.documentation()];
     },
 
     selectedHeader: "Databases",

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/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 f833ded..8dd283b 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -28,6 +28,8 @@ function(app, FauxtonAPI) {
         return this.getDatabase().url("app") + "/" + this.safeID();
       } else if (context === "web-index") {
         return this.getDatabase().url("app") + "/" + app.mixins.safeURLName(this.id);
+      } else if (context === "apiurl"){
+        return window.location.origin + "/" + this.getDatabase().safeID() + "/" + this.safeID();
       } else {
         return app.host + "/" + this.getDatabase().safeID() + "/" + this.safeID();
       }
@@ -206,6 +208,8 @@ function(app, FauxtonAPI) {
     url: function(context) {
       if (context === "app") {
         return this.database.url("app") + "/" + this.safeID() + '/_info';
+      } else if (context === "apiurl"){
+        return window.location.origin + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
       } else {
         return app.host + "/" + this.database.safeID() + "/" + this.safeID() + '/_info';
       }
@@ -287,8 +291,11 @@ function(app, FauxtonAPI) {
 
       if (context === 'app') {
         return 'database/' + this.database.safeID() + "/_all_docs" + query;
+      } else if (context === "apiurl"){
+        return window.location.origin + "/" + this.database.safeID() + "/_all_docs" + query;
+      } else {
+        return app.host + "/" + this.database.safeID() + "/_all_docs" + query;
       }
-      return app.host + "/" + this.database.safeID() + "/_all_docs" + query;
     },
 
     simple: function () {
@@ -412,6 +419,8 @@ function(app, FauxtonAPI) {
       var startOfUrl = app.host;
       if (context === 'app') {
         startOfUrl = 'database';
+      } else if (context === "apiurl"){
+        startOfUrl = window.location.origin;
       }
       var design = app.mixins.safeURLName(this.design),
           view = app.mixins.safeURLName(this.view);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f3c9b4c7/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
index 56cdc1b..538cd56 100644
--- a/src/fauxton/app/modules/documents/routes.js
+++ b/src/fauxton/app/modules/documents/routes.js
@@ -107,7 +107,7 @@ function(app, FauxtonAPI, Documents, Databases) {
     },
 
     apiUrl: function() {
-      return [this.doc.url(), this.doc.documentation()];
+      return [this.doc.url("apiurl"), this.doc.documentation()];
     }
   });
 
@@ -218,7 +218,7 @@ function(app, FauxtonAPI, Documents, Databases) {
         {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
       ];
 
-      this.apiUrl = [this.data.database.allDocs.url(), this.data.database.allDocs.documentation() ];
+      this.apiUrl = [this.data.database.allDocs.url("apiurl"), this.data.database.allDocs.documentation() ];
     },
 
     viewFn: function (databaseName, ddoc, view) {
@@ -270,7 +270,7 @@ function(app, FauxtonAPI, Documents, Databases) {
         ];
       };
 
-      this.apiUrl = [this.data.indexedDocs.url(), "docs"];
+      this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
     },
 
     newViewEditor: function () {
@@ -397,7 +397,7 @@ function(app, FauxtonAPI, Documents, Databases) {
     },
 
     apiUrl: function() {
-      return [this.database.url(), this.database.documentation()];
+      return [this.database.url("apiurl"), this.database.documentation()];
     }
 
   });