diff options
author | suelockwood <deathbear@apache.org> | 2013-12-23 11:01:34 -0500 |
---|---|---|
committer | suelockwood <deathbear@apache.org> | 2013-12-23 11:02:59 -0500 |
commit | f3c9b4c70aceea221e3c671634ebfb0428e67371 (patch) | |
tree | 093c4b7299bad0084a9b3a8ec51ecee80e057d81 | |
parent | 8db54be26033309bdce18a0662d80d011847ba69 (diff) | |
download | couchdb-ENCODE-EVERYTHING.tar.gz |
Fix API urlsENCODE-EVERYTHING
Fix data size
-rw-r--r-- | src/fauxton/app/addons/activetasks/resources.js | 8 | ||||
-rw-r--r-- | src/fauxton/app/addons/activetasks/routes.js | 2 | ||||
-rw-r--r-- | src/fauxton/app/modules/databases/resources.js | 25 | ||||
-rw-r--r-- | src/fauxton/app/modules/databases/routes.js | 2 | ||||
-rw-r--r-- | src/fauxton/app/modules/documents/resources.js | 11 | ||||
-rw-r--r-- | src/fauxton/app/modules/documents/routes.js | 8 |
6 files changed, 42 insertions, 14 deletions
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js index 46258718c..ca732fbc7 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 || {}; diff --git a/src/fauxton/app/addons/activetasks/routes.js b/src/fauxton/app/addons/activetasks/routes.js index e0454b7a4..89bcfcc36 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"], diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js index a01c9cee9..a716ea111 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) { diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js index e63c3a769..ca3d64005 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", diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js index f833dede2..8dd283b91 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); diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js index 56cdc1b13..538cd56eb 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()]; } }); |