diff --git a/app/addons/databases/actions.js b/app/addons/databases/actions.js index d576c7e1b..c96c5e4b2 100644 --- a/app/addons/databases/actions.js +++ b/app/addons/databases/actions.js @@ -12,7 +12,7 @@ import app from '../../app'; import Helpers from '../../helpers'; import FauxtonAPI from '../../core/api'; -import { get } from '../../core/ajax'; +import { get, post } from '../../core/ajax'; import DatabasesBase from '../databases/base'; import Stores from './stores'; import ActionTypes from './actiontypes'; @@ -21,29 +21,30 @@ import * as API from './api'; function getDatabaseDetails (dbList, fullDbList) { const databaseDetails = []; const failedDbs = []; - let seen = 0; - dbList.forEach((db) => { - const url = FauxtonAPI.urls('databaseBaseURL', 'server', db); - - fetch(url) - .then((res) => { - databaseDetails.push(res); - }).catch(() => { - failedDbs.push(db); - }).then(() => { - seen++; - if (seen !== dbList.length) { - return; + const url = FauxtonAPI.urls('dbsInfo', 'server'); + const body = { + keys: dbList + }; + post(url, body) + .then((res) => { + res.forEach((db) => { + if (db.info !== undefined) { + databaseDetails.push(db); + } else { + failedDbs.push(db.key); } - updateDatabases({ - dbList: dbList, - databaseDetails: databaseDetails, - failedDbs: failedDbs, - fullDbList: fullDbList - }); }); - }); + }).catch(() => { + failedDbs.push(...dbList); + }).then(() => { + updateDatabases({ + dbList: dbList, + databaseDetails: databaseDetails, + failedDbs: failedDbs, + fullDbList: fullDbList + }); + }); } function fetch (url) { diff --git a/app/addons/databases/base.js b/app/addons/databases/base.js index 8cfd0d33f..655215c4c 100644 --- a/app/addons/databases/base.js +++ b/app/addons/databases/base.js @@ -108,6 +108,12 @@ FauxtonAPI.registerUrls('databaseBaseURL', { } }); +FauxtonAPI.registerUrls('dbsInfo', { + server: function () { + return Helpers.getServerUrl('/_dbs_info'); + } +}); + FauxtonAPI.registerUrls('permissions', { server: function (db) { return Helpers.getServerUrl('/' + db + '/_security');