diff --git a/js/apps/system/aardvark/frontend/css/dbSelectionView.css b/js/apps/system/aardvark/frontend/css/dbSelectionView.css
index f4deadedb8..91e057b929 100644
--- a/js/apps/system/aardvark/frontend/css/dbSelectionView.css
+++ b/js/apps/system/aardvark/frontend/css/dbSelectionView.css
@@ -1,12 +1,8 @@
-span.selectDB {
- top: 6px;
- left: 210px;
- position: absolute;
-}
-
span.selectDB > select {
line-height: 20px;
height: 20px;
width: 150px;
- padding: 0px;
+ margin: -3px 0px 2px 0px;
+ border-radius: 0px !important;
+ border: 1px solid;
}
diff --git a/js/apps/system/aardvark/frontend/js/routers/router.js b/js/apps/system/aardvark/frontend/js/routers/router.js
index 8945e81443..183de137ba 100644
--- a/js/apps/system/aardvark/frontend/js/routers/router.js
+++ b/js/apps/system/aardvark/frontend/js/routers/router.js
@@ -69,10 +69,6 @@
this.graphView = new window.GraphView({
collection: window.arangoCollectionsStore
});
- this.dbSelectionView = new window.DBSelectionView({
- collection: window.arangoDatabase,
- current: window.currentDB
- });
var self = this;
$(window).resize(function() {
@@ -343,7 +339,7 @@
},
handleSelectDatabase: function () {
- this.dbSelectionView.render($("#selectDB"));
+ this.footerView.handleSelectDatabase();
},
handleResize: function () {
diff --git a/js/apps/system/aardvark/frontend/js/templates/dbSelectionView.ejs b/js/apps/system/aardvark/frontend/js/templates/dbSelectionView.ejs
index 0988045d52..67179d4e79 100644
--- a/js/apps/system/aardvark/frontend/js/templates/dbSelectionView.ejs
+++ b/js/apps/system/aardvark/frontend/js/templates/dbSelectionView.ejs
@@ -12,5 +12,9 @@ if (list.length > 1) {
%>
<%
+} else {
+%>
+ <%=current%>
+<%
}
%>
diff --git a/js/apps/system/aardvark/frontend/js/templates/footerView.ejs b/js/apps/system/aardvark/frontend/js/templates/footerView.ejs
index 4da97d2617..b96f9cf6ca 100644
--- a/js/apps/system/aardvark/frontend/js/templates/footerView.ejs
+++ b/js/apps/system/aardvark/frontend/js/templates/footerView.ejs
@@ -12,6 +12,6 @@
diff --git a/js/apps/system/aardvark/frontend/js/views/dbSelectionView.js b/js/apps/system/aardvark/frontend/js/views/dbSelectionView.js
index e218abc1bf..df9debf6ac 100644
--- a/js/apps/system/aardvark/frontend/js/views/dbSelectionView.js
+++ b/js/apps/system/aardvark/frontend/js/views/dbSelectionView.js
@@ -4,8 +4,6 @@
"use strict";
window.DBSelectionView = Backbone.View.extend({
- el: "#dbSelect",
-
template: templateEngine.createTemplate("dbSelectionView.ejs"),
events: {
@@ -16,9 +14,7 @@
var self = this;
this.current = opts.current;
this.collection.fetch({
- success: function() {
- self.render();
- }
+ async: false
});
},
@@ -28,13 +24,14 @@
window.location.replace(url);
},
- render: function() {
- $(this.el).html(this.template.render({
+ render: function(el) {
+ this.$el = el;
+ this.$el.html(this.template.render({
list: this.collection,
current: this.current.get("name")
}));
this.delegateEvents();
- return $(this.el);
+ return this.el;
}
});
}());
diff --git a/js/apps/system/aardvark/frontend/js/views/footerView.js b/js/apps/system/aardvark/frontend/js/views/footerView.js
index 81ac2bd8c7..e086233400 100644
--- a/js/apps/system/aardvark/frontend/js/views/footerView.js
+++ b/js/apps/system/aardvark/frontend/js/views/footerView.js
@@ -11,6 +11,10 @@
initialize: function () {
//also server online check
var self = this;
+ this.dbSelectionView = new window.DBSelectionView({
+ collection: window.arangoDatabase,
+ current: window.currentDB
+ });
window.setInterval(function(){
self.getVersion();
}, 15000);
@@ -90,6 +94,7 @@
},
renderVersion: function () {
+ var self = this;
if (this.system.hasOwnProperty('database') && this.system.hasOwnProperty('name')) {
$(this.el).html(this.template.render({
name: this.system.name,
@@ -97,11 +102,7 @@
database: this.system.database,
margin: this.resizeMargin
}));
- /*
- var tag = 'Server: ' + this.system.name + ' ' + this.system.version +
- ', Database: ' + this.system.database;
- $('.footer-right p').html(tag);
- */
+ this.dbSelectionView.render($("#dbSelect"));
}
},
@@ -110,7 +111,12 @@
this.render();
},
+ handleSelectDatabase: function() {
+ this.dbSelectionView.render();
+ },
+
render: function () {
+ var self = this;
if (!this.system.version) {
this.getVersion();
}
@@ -120,6 +126,7 @@
database: this.system.database,
margin: this.resizeMargin
}));
+ this.dbSelectionView.render($("#dbSelect"));
return this;
}
diff --git a/js/apps/system/aardvark/frontend/js/views/navigationView.js b/js/apps/system/aardvark/frontend/js/views/navigationView.js
index f564fdd344..5a0b3580f7 100644
--- a/js/apps/system/aardvark/frontend/js/views/navigationView.js
+++ b/js/apps/system/aardvark/frontend/js/views/navigationView.js
@@ -18,9 +18,8 @@
},
handleResize: function (margin) {
- $('.arango-logo').css('margin-left', margin - 17);
- $("#dbSelect").css('margin-left', margin - 17);
- $('.nav-collapse').css('margin-right', margin - 10);
+ $('.arango-logo').css('margin-left', margin - 41);
+ $('.nav-collapse').css('margin-right', margin + 7);
},
diff --git a/js/apps/system/aardvark/index.html b/js/apps/system/aardvark/index.html
index 4938a63193..6de7868158 100644
--- a/js/apps/system/aardvark/index.html
+++ b/js/apps/system/aardvark/index.html
@@ -20,7 +20,6 @@

-
diff --git a/js/apps/system/aardvark/test/specs/router/routerSpec.js b/js/apps/system/aardvark/test/specs/router/routerSpec.js
index d30686e9b3..17af29a7c5 100644
--- a/js/apps/system/aardvark/test/specs/router/routerSpec.js
+++ b/js/apps/system/aardvark/test/specs/router/routerSpec.js
@@ -15,7 +15,6 @@
footerDummy,
documentDummy,
documentsDummy,
- databaseDummy,
sessionDummy,
graphDummy,
logsDummy;
@@ -32,7 +31,6 @@
};
documentDummy = {};
documentsDummy = {};
- databaseDummy = {};
graphDummy = {
handleResize: function() {}
};
@@ -48,7 +46,6 @@
spyOn(storeDummy, "fetch");
spyOn(window, "arangoCollections").andReturn(storeDummy);
spyOn(window, "ArangoSession").andReturn(sessionDummy);
- spyOn(window, "ArangoDatabase").andReturn(databaseDummy);
spyOn(window, "arangoDocuments").andReturn(documentsDummy);
spyOn(window, "arangoDocument").andReturn(documentDummy);
spyOn(window, "CollectionsView");
@@ -91,7 +88,7 @@
spyOn(window, "DBSelectionView");
});
- describe("Initialisation", function() {
+ describe("initialisation", function() {
var r;
@@ -135,13 +132,6 @@
});
});
- it("should create the dbSelectionView", function() {
- expect(window.DBSelectionView).toHaveBeenCalledWith({
- collection: databaseDummy,
- current: fakeDB
- });
- });
-
it("should fetch the collectionsStore", function() {
expect(storeDummy.fetch).toHaveBeenCalled();
});
diff --git a/js/apps/system/aardvark/test/specs/views/dbSelectionViewSpec.js b/js/apps/system/aardvark/test/specs/views/dbSelectionViewSpec.js
index 984ade352f..c09f8aafc8 100644
--- a/js/apps/system/aardvark/test/specs/views/dbSelectionViewSpec.js
+++ b/js/apps/system/aardvark/test/specs/views/dbSelectionViewSpec.js
@@ -25,13 +25,16 @@
dbCollection.add({name: n});
});
fetched = false;
- spyOn(dbCollection, "fetch").andCallFake(function(opt) {
- fetched = true;
- opt.success();
- });
+ spyOn(dbCollection, "fetch");
div = document.createElement("div");
div.id = "dbSelect";
document.body.appendChild(div);
+ view = new DBSelectionView(
+ {
+ collection: dbCollection,
+ current: current
+ }
+ );
});
afterEach(function() {
@@ -39,114 +42,48 @@
});
it("should display all databases ordered", function() {
-
- runs(function() {
- view = new DBSelectionView(
- {
- collection: dbCollection,
- current: current
- }
- );
- });
-
- waitsFor(function() {
- return fetched;
- }, 1000);
-
- runs(function() {
- var select = $(div).children()[0],
- childs;
- expect(div.childElementCount).toEqual(1);
- childs = $(select).children();
- expect(childs.length).toEqual(3);
- expect(childs[0].id).toEqual(list[0]);
- expect(childs[1].id).toEqual(list[2]);
- expect(childs[2].id).toEqual(list[1]);
- });
+ view.render($(div));
+ var select = $(div).children()[0],
+ childs;
+ expect(div.childElementCount).toEqual(1);
+ childs = $(select).children();
+ expect(childs.length).toEqual(3);
+ expect(childs[0].id).toEqual(list[0]);
+ expect(childs[1].id).toEqual(list[2]);
+ expect(childs[2].id).toEqual(list[1]);
});
it("should select the current db", function() {
- runs(function() {
- view = new DBSelectionView(
- {
- collection: dbCollection,
- current: current
- }
- );
- });
-
- waitsFor(function() {
- return fetched;
- }, 1000);
-
- runs(function() {
- expect($(div).find(":selected").attr("id")).toEqual(current.get("name"));
- });
+ view.render($(div));
+ expect($(div).find(":selected").attr("id")).toEqual(current.get("name"));
});
it("should trigger fetch on collection", function() {
- runs(function() {
- view = new DBSelectionView(
- {
- collection: dbCollection,
- current: current
- }
- );
- });
-
- waitsFor(function() {
- return fetched;
- }, 1000);
-
- runs(function() {
- expect(dbCollection.fetch).toHaveBeenCalled();
- });
+ view.render($(div));
+ expect(dbCollection.fetch).toHaveBeenCalled();
});
it("should trigger a database switch on click", function() {
- runs(function() {
- view = new DBSelectionView(
- {
- collection: dbCollection,
- current: current
- }
- );
- });
-
- waitsFor(function() {
- return fetched;
- }, 1000);
-
- runs(function() {
- spyOn(dbCollection, "createDatabaseURL").andReturn("switchURL");
- spyOn(location, "replace");
- $("#dbSelectionList").val("second").trigger("change");
- expect(dbCollection.createDatabaseURL).toHaveBeenCalledWith("second");
- expect(location.replace).toHaveBeenCalledWith("switchURL");
- });
+ view.render($(div));
+ spyOn(dbCollection, "createDatabaseURL").andReturn("switchURL");
+ spyOn(location, "replace");
+ $("#dbSelectionList").val("second").trigger("change");
+ expect(dbCollection.createDatabaseURL).toHaveBeenCalledWith("second");
+ expect(location.replace).toHaveBeenCalledWith("switchURL");
});
- it("should not render if the list has only one element", function() {
- runs(function() {
- var oneCollection = new window.ArangoDatabase();
- oneCollection.add({name: current});
- spyOn(oneCollection, "fetch").andCallFake(function(opts) {
- fetched = true;
- opts.success();
- });
- view = new DBSelectionView({
+ it("should not render the selection if the list has only one element", function() {
+ var oneCollection = new window.ArangoDatabase();
+ oneCollection.add({name: current});
+ spyOn(oneCollection, "fetch");
+ view = new DBSelectionView(
+ {
collection: oneCollection,
current: current
- });
- });
-
- waitsFor(function() {
- return fetched;
- }, 1000);
-
- runs(function() {
- expect($(div).text().trim()).toEqual("");
- });
+ }
+ );
+ view.render($(div));
+ expect($(div).text().trim()).toEqual("first");
});
});
}());