diff --git a/js/apps/system/aardvark/aardvark.js b/js/apps/system/aardvark/aardvark.js index 9535b8bf69..cee40cf5e6 100644 --- a/js/apps/system/aardvark/aardvark.js +++ b/js/apps/system/aardvark/aardvark.js @@ -40,6 +40,9 @@ var FoxxController = require("org/arangodb/foxx").Controller, foxxInstallKey = joi.string().required().description( "The _key attribute, where the information of this Foxx-Install is stored." ), + foxxMountPoint = joi.string().required().description( + "The mount point, where this Foxx is installed." + ), appname = joi.string().required(); var foxxes = new (require("lib/foxxes").Foxxes)(); @@ -286,13 +289,17 @@ controller.get('/docus', function (req, res) { * */ -controller.get("/docu/:key",function (req, res) { +controller.get("/docu/:mount", function (req, res) { + require("console").log("Paul"); var subPath = req.path.substr(0, req.path.lastIndexOf("[") - 1), - key = req.params("key"), - path = req.protocol + "://" + req.headers.host + - "/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(key) + "/"; - res.json(docus.listOne(path, key)); -}).summary("List documentation of one foxxes.") + mount = req.params("mount"), + path = req.protocol + "://" + req.headers.host + "/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(mount) + "/"; + require("console").log(docus.listOne(path, mount)); + res.json(docus.listOne(path, mount)); +}).pathParam("mount", { + type: foxxMountPoint, + allowMultiple: false +}).summary("List documentation of all foxxes.") .notes("This function simply returns one specific" + " foxx and supplies the paths for the swagger documentation"); @@ -301,12 +308,18 @@ controller.get("/docu/:key",function (req, res) { * Get the Elements of the API Documentation subroutes * */ -controller.get('/docu/:key/*', function(req, res) { - var mountPoint = ""; - underscore.each(req.suffix, function(part) { - mountPoint += "/" + part; - }); +controller.get('/docu/:mount/:mountPoint', function(req, res) { + require("console").log("Blub"); + require("console").log(req.params("mount")); + var mountPoint = decodeURIComponent(req.params("mountPoint")); + require("console").log(mountPoint); res.json(docus.show(mountPoint)); +}).pathParam("mount", { + type: foxxMountPoint, + allowMultiple: false +}).pathParam("mountPoint", { + type: foxxMountPoint, + allowMultiple: false }).summary("List the API for one foxx") .notes("This function lists the API of the foxx" + " running under the given mount point"); diff --git a/js/apps/system/aardvark/frontend/js/routers/router.js b/js/apps/system/aardvark/frontend/js/routers/router.js index 92fe915bd9..d9f30a820b 100644 --- a/js/apps/system/aardvark/frontend/js/routers/router.js +++ b/js/apps/system/aardvark/frontend/js/routers/router.js @@ -19,7 +19,7 @@ "api": "api", "databases": "databases", "applications": "applications", - "application/documentation/:key": "appDocumentation", + "application/documentation/:mount": "appDocumentation", "graph": "graphManagement", "userManagement": "userManagement", "userProfile": "userProfile", @@ -242,8 +242,8 @@ this.naviView.selectMenuItem('applications-menu'); }, - appDocumentation: function (key) { - var docuView = new window.AppDocumentationView({key: key}); + appDocumentation: function (mount) { + var docuView = new window.AppDocumentationView({mount: mount}); docuView.render(); this.naviView.selectMenuItem('applications-menu'); }, diff --git a/js/apps/system/aardvark/frontend/js/views/appDocumentationView.js b/js/apps/system/aardvark/frontend/js/views/appDocumentationView.js index 452cc69f84..50e0983f6e 100644 --- a/js/apps/system/aardvark/frontend/js/views/appDocumentationView.js +++ b/js/apps/system/aardvark/frontend/js/views/appDocumentationView.js @@ -13,7 +13,7 @@ initialize: function() { var internal = require("internal"); - var url = internal.arango.databasePrefix("/_admin/aardvark/docu/" + this.options.key); + var url = internal.arango.databasePrefix("/_admin/aardvark/docu/" + encodeURIComponent(this.options.mount)); this.swaggerUi = new SwaggerUi({ discoveryUrl: url, apiKey: false, diff --git a/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js b/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js index ede5b41533..3ef097bcde 100644 --- a/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js +++ b/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js @@ -208,7 +208,7 @@ showDocu: function(event) { event.stopPropagation(); window.App.navigate( - "application/documentation/" + encodeURIComponent(this.model.get("_key")), + "application/documentation/" + encodeURIComponent(this.model.get("mount").substr(1)), { trigger: true } diff --git a/js/apps/system/aardvark/lib/swagger.js b/js/apps/system/aardvark/lib/swagger.js index f4a3ebeb13..121a9f5eaf 100644 --- a/js/apps/system/aardvark/lib/swagger.js +++ b/js/apps/system/aardvark/lib/swagger.js @@ -47,42 +47,35 @@ exports.Swagger = function () { result.swaggerVersion = "1.1"; result.basePath = basePath; result.apis = apis; + var m; while (res.hasNext()) { - var m = res.next().mount; - if (m === "/aardvark") { - - } else { + m = res.next().mount; + if (m !== "/aardvark") { apis.push({ path: m }); } } return result; - }, + }; - this.listOne = function(basePath, key) { - var result = {}, - res; - - if (key.substr(0, 4) === "dev:") { - res = "/dev/" + key.split(":")[2]; - } - else { - res = _aal.document(key).mount; - } + this.listOne = function(basePath, mount) { + var result = {}; result.swaggerVersion = "1.1"; result.basePath = basePath; result.apis = [ - {path: res} + {path: decodeURIComponent(mount)} ]; + require("console").log(result); return result; - }, + }; // Get details of one specific installed foxx. this.show = function(mount) { + require("console").log(mount); var result = {}, apis = [], pathes, @@ -109,18 +102,20 @@ exports.Swagger = function () { pathes = app.routes; for (i in pathes) { - if (pathes[i].url.methods !== undefined) { - url = pathes[i].url.match; - api = {}; - ops = []; - url = url.replace(regex, "{$2}"); - api.path = url; - ops.push(pathes[i].docs); - api.operations = ops; - apis.push(api); + if(pathes.hasOwnProperty(i)){ + if (pathes[i].url.methods !== undefined) { + url = pathes[i].url.match; + api = {}; + ops = []; + url = url.replace(regex, "{$2}"); + api.path = url; + ops.push(pathes[i].docs); + api.operations = ops; + apis.push(api); + } } } return result; - } + }; }; diff --git a/js/apps/system/aardvark/test/karma/files.json b/js/apps/system/aardvark/test/karma/files.json index 1b07aeea47..6c41384585 100755 --- a/js/apps/system/aardvark/test/karma/files.json +++ b/js/apps/system/aardvark/test/karma/files.json @@ -32,6 +32,7 @@ "frontend/js/lib/swagger-ui.js", "frontend/js/lib/highlight.7.3.pack.js", "frontend/js/lib/joi.browser.js", + "frontend/js/lib/md5.js", "test/mocks/disableEJS.js", "frontend/js/arango/arango.js", "frontend/js/shell/browser.js", @@ -193,19 +194,6 @@ "test/specs/views/statisticBarViewSpec.js", "test/specs/views/shellViewSpec.js", "test/specs/views/queryViewSpec.js", - "test/specs/views/userManagementViewSpec.js", - - "test/clusterSpecs/views/clusterDownViewSpec.js", - "test/clusterSpecs/views/dbServerDashboardViewSpec.js", - "test/clusterSpecs/views/loginModalViewSpec.js", - "test/clusterSpecs/views/planScenarioSelectorViewSpec.js", - "test/clusterSpecs/views/planSymmetricViewSpec.js", - "test/clusterSpecs/views/planTestViewSpec.js", - "test/clusterSpecs/views/showClusterViewSpec.js", - "test/clusterSpecs/views/shutdownButtonViewSpec.js", - - "test/specs/router/routerSpec.js", - "test/specs/router/clusterRouterSpec.js", "test/specs/router/versionCheckSpec.js" ] diff --git a/js/apps/system/aardvark/test/karma/karma.conf.js b/js/apps/system/aardvark/test/karma/karma.conf.js index fe3af09da7..bc0f3b7d66 100644 --- a/js/apps/system/aardvark/test/karma/karma.conf.js +++ b/js/apps/system/aardvark/test/karma/karma.conf.js @@ -45,7 +45,7 @@ module.exports = function(karma) { // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + autoWatch: true, // Start these browsers, currently available: @@ -64,6 +64,6 @@ module.exports = function(karma) { // Continuous Integration mode // if true, it capture browsers, run tests and exit - singleRun: true + singleRun: false }); };