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 88D451077D for ; Mon, 23 Dec 2013 17:21:36 +0000 (UTC) Received: (qmail 71289 invoked by uid 500); 23 Dec 2013 17:21:01 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 71035 invoked by uid 500); 23 Dec 2013 17:20:54 -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 70855 invoked by uid 99); 23 Dec 2013 17:20:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Dec 2013 17:20:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C490E88F415; Mon, 23 Dec 2013 17:20:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: deathbear@apache.org To: commits@couchdb.apache.org Date: Mon, 23 Dec 2013 17:20:44 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: updated refs/heads/master to b0bf0f3 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/b0bf0f36 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b0bf0f36 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b0bf0f36 Branch: refs/heads/master Commit: b0bf0f369f46b027c03b258344923cea36cb75c8 Parents: d33b7df Author: suelockwood Authored: Mon Dec 23 11:01:34 2013 -0500 Committer: suelockwood Committed: Mon Dec 23 12:20:30 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/b0bf0f36/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/b0bf0f36/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/b0bf0f36/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/b0bf0f36/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/b0bf0f36/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/b0bf0f36/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()]; } });