diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js index d67fc95f51..9baf27f2ce 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/arango/arango.js @@ -132,19 +132,14 @@ }, currentDatabase: function (callback) { - $.ajax({ - type: "GET", - cache: false, - url: this.databaseUrl("/_api/database/current"), - contentType: "application/json", - processData: false, - success: function(data) { - callback(false, data.result.name); - }, - error: function(data) { - callback(true, data); - } - }); + if (frontendConfig.db) { + callback(false, frontendConfig.db); + } + else { + callback(true, undefined); + } + console.log(frontendConfig.db); + return frontendConfig.db; }, allHotkeys: { @@ -501,6 +496,7 @@ } }, error: function(data) { + console.log("error"); if (callback) { callback(true, data); } diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/models/arangoCollectionModel.js b/js/apps/system/_admin/aardvark/APP/frontend/js/models/arangoCollectionModel.js index a9ce3ff430..2a1b7cc82c 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/models/arangoCollectionModel.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/models/arangoCollectionModel.js @@ -36,7 +36,7 @@ $.ajax({ type: "GET", cache: false, - url: arangoHelper.databaseHelper("/_api/collection/" + this.get("id") + "/figures"), + url: arangoHelper.databaseUrl("/_api/collection/" + this.get("id") + "/figures"), contentType: "application/json", processData: false, success: function(data) { diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/models/currentDatabase.js b/js/apps/system/_admin/aardvark/APP/frontend/js/models/currentDatabase.js index 345c5a34f6..64b724acf7 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/models/currentDatabase.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/models/currentDatabase.js @@ -1,10 +1,10 @@ -/*global Backbone, window, arangoHelper */ +/*global Backbone, window, arangoHelper, frontendConfig */ (function() { "use strict"; window.CurrentDatabase = Backbone.Model.extend({ - url: arangoHelper.databaseUrl("/_api/database/current"), + url: arangoHelper.databaseUrl("/_api/database/current", frontendConfig.db), parse: function(data) { return data.result; diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js index 8da55ad41e..775ef11b33 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/routers/router.js @@ -1,6 +1,6 @@ /*jshint unused: false */ /*global window, $, Backbone, document, arangoCollectionModel*/ -/*global arangoHelper, btoa, dashboardView, arangoDatabase, _*/ +/*global arangoHelper, btoa, dashboardView, arangoDatabase, _, frontendConfig */ (function () { "use strict"; @@ -54,26 +54,45 @@ }, checkUser: function () { + if (window.location.hash === '#login') { return; } + var startInit = function() { + this.initOnce(); + + //show hidden by default divs + $('.bodyWrapper').show(); + $('.navbar').show(); + }.bind(this); + var callback = function(error, user) { - if (error || user === null) { - if (window.location.hash !== '#login') { - this.navigate("login", {trigger: true}); + if (frontendConfig.authenticationEnabled) { + if (error || user === null) { + if (window.location.hash !== '#login') { + this.navigate("login", {trigger: true}); + } + } + else { + startInit(); } } else { - this.initOnce(); - - //show hidden by default divs - $('.bodyWrapper').show(); - $('.navbar').show(); + startInit(); } }.bind(this); - this.userCollection.whoAmI(callback); + if (frontendConfig.authenticationEnabled) { + this.userCollection.whoAmI(callback); + } + else { + this.initOnce(); + + //show hidden by default divs + $('.bodyWrapper').show(); + $('.navbar').show(); + } }, waitForInit: function(origin, param1, param2) { @@ -88,7 +107,7 @@ if (param1 && param2) { origin(param1, param2, false); } - }, 250); + }, 350); } else { if (!param1) { origin(true); @@ -123,7 +142,7 @@ var callback = function(error, isCoordinator) { self = this; - if (isCoordinator) { + if (isCoordinator === true) { self.isCluster = true; self.coordinatorCollection.fetch({ @@ -209,11 +228,11 @@ cluster: function (initialized) { this.checkUser(); - if (!initialized || this.isCluster === undefined) { + if (!initialized) { this.waitForInit(this.cluster.bind(this)); return; } - if (this.isCluster === false) { + if (this.isCluster === false || this.isCluster === undefined) { if (this.currentDB.get("name") === '_system') { this.routes[""] = 'dashboard'; this.navigate("#dashboard", {trigger: true}); @@ -409,16 +428,16 @@ login: function () { var callback = function(error, user) { + if (!this.loginView) { + this.loginView = new window.loginView({ + collection: this.userCollection + }); + } if (error || user === null) { - if (!this.loginView) { - this.loginView = new window.loginView({ - collection: this.userCollection - }); - } this.loginView.render(); } else { - this.navigate("", {trigger: true}); + this.loginView.render(true); } }.bind(this); diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/subNavigationView.ejs b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/subNavigationView.ejs index 52aeb8c9ce..da57dba94a 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/subNavigationView.ejs +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/subNavigationView.ejs @@ -4,22 +4,21 @@ - - diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/userBarView.ejs b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/userBarView.ejs index 982b6d5a6f..a7939e0c45 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/templates/userBarView.ejs +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/templates/userBarView.ejs @@ -1,9 +1,10 @@