1
0
Fork 0

Improved the overview and added a seperate coordinators view, it is actually completely different compared to db servers

This commit is contained in:
Michael Hackstein 2014-01-15 17:08:56 +01:00
parent 6feeab89b6
commit a4e500ebf5
7 changed files with 109 additions and 41 deletions

View File

@ -272,8 +272,5 @@ button.gv-zoom-btn.pan-bottom{
} }
button.btn-overview { button.btn-overview {
margin-left: 0px; margin: 5px;
width: 140px;
margin-top: 5px;
margin-bottom: 5px;
} }

View File

@ -0,0 +1,14 @@
<h3 class="clusterColumnHeader">Coordinators</h3>
<div class="pull-right">
<ul>
<li>
<button id="Pavel" class="server">Pavel</button>
</li>
<li>
<button id="Paul" class="server">Paul</button>
</li>
<li>
<button id="Peter" class="server">Peter</button>
</li>
</ul>
</div>

View File

@ -23,21 +23,21 @@
</div> </div>
<% } else { %> <% } else { %>
<div id="dbserver" class="tile tile-left btn-<%=statusClass(dbservers.status)%>"> <div id="dbserver" class="tile tile-left btn-<%=statusClass(dbservers.status)%>">
<span>Data Servers</span> <h4 class="cluster-tile">Data Servers</h4>
<br> <div>
<br> <span class="arangoicon icon_arangodb_database1 cluster_icon_large"></span>
<span class="arangoicon icon_arangodb_database1 cluster_icon_large"></span>
<div id=dbserversAmounts" class="clusterAmounts">
<%=dbservers.having %>/<%=dbservers.plan %>
</div> </div>
<h4 id=dbserversAmounts" class="clusterAmounts">
<%=dbservers.having %>/<%=dbservers.plan %>
</h4>
</div> </div>
<div id="coordinator" class="tile tile-right btn-<%=statusClass(coordinators.status)%>"> <div id="coordinator" class="tile tile-right btn-<%=statusClass(coordinators.status)%>">
<span>Coordinators</span> <h4 class="cluster-tile">Coordinators</h4>
<br> <div>
<br> <span class="arangoicon icon_arangodb_compass cluster_icon_large"></span>
<span class="arangoicon icon_arangodb_compass cluster_icon_large"></span>
<div id=coordinatorAmounts" class="clusterAmounts">
<%=coordinators.having %>/<%=coordinators.plan %>
</div> </div>
<h4 id=coordinatorAmounts" class="clusterAmounts">
<%=coordinators.having %>/<%=coordinators.plan %>
</h4>
</div> </div>
<% } %> <% } %>

View File

@ -0,0 +1,20 @@
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true*/
/*global Backbone, templateEngine, $, window */
(function() {
"use strict";
window.ClusterCoordinatorView = Backbone.View.extend({
el: '#clusterServers',
template: templateEngine.createTemplate("clusterCoordinatorView.ejs"),
render: function(){
$(this.el).html(this.template.render({}));
return this;
}
});
}());

View File

@ -30,19 +30,16 @@
}; };
this.serverView = new window.ClusterServerView(); this.serverView = new window.ClusterServerView();
this.coordinatorView = new window.ClusterCoordinatorView();
}, },
loadDBServers: function() { loadDBServers: function() {
this.serverView.render({ this.serverView.render();
type: "dbservers"
});
this.render(true); this.render(true);
}, },
loadCoordinators: function() { loadCoordinators: function() {
this.serverView.render({ this.coordinatorView.render();
type: "coordinator"
});
this.render(true); this.render(true);
}, },

View File

@ -0,0 +1,36 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
/*global describe, beforeEach, afterEach, it, */
/*global spyOn, expect*/
/*global templateEngine, $*/
(function() {
"use strict";
describe("Cluster Coordinator View", function() {
var view, div;
beforeEach(function() {
div = document.createElement("div");
div.id = "clusterServers";
document.body.appendChild(div);
});
afterEach(function() {
document.body.removeChild(div);
});
describe("rendering", function() {
beforeEach(function() {
view = new window.ClusterCoordinatorView();
});
it("should render the coordinators", function() {
view.render();
});
});
});
}());

View File

@ -6,16 +6,20 @@
"use strict"; "use strict";
describe("Cluster Overview View", function() { describe("Cluster Overview View", function() {
var view, div, serverView; var view, div, serverView, coordinatorView;
beforeEach(function() { beforeEach(function() {
div = document.createElement("div"); div = document.createElement("div");
div.id = "clusterOverview"; div.id = "clusterOverview";
document.body.appendChild(div); document.body.appendChild(div);
serverView = { serverView = {
render: function(){} render: function() {}
};
coordinatorView = {
render: function() {}
}; };
spyOn(window, "ClusterServerView").andReturn(serverView); spyOn(window, "ClusterServerView").andReturn(serverView);
spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView);
this.addMatchers({ this.addMatchers({
toBeTag: function(name) { toBeTag: function(name) {
@ -66,25 +70,20 @@
beforeEach(function() { beforeEach(function() {
serverView.render.reset(); serverView.render.reset();
coordinatorView.render.reset();
view.render(); view.render();
spyOn(view, "render"); spyOn(view, "render");
}); });
it("should be able to navigate to db servers", function() { it("should be able to navigate to db servers", function() {
info = {
type: "dbservers"
};
$("#dbserver").click(); $("#dbserver").click();
expect(serverView.render).toHaveBeenCalledWith(info); expect(serverView.render).toHaveBeenCalledWith();
expect(view.render).toHaveBeenCalledWith(true); expect(view.render).toHaveBeenCalledWith(true);
}); });
it("should be able to navigate to primary servers", function() { it("should be able to navigate to coordinators", function() {
info = {
type: "coordinator"
};
$("#coordinator").click(); $("#coordinator").click();
expect(serverView.render).toHaveBeenCalledWith(info); expect(coordinatorView.render).toHaveBeenCalledWith();
expect(view.render).toHaveBeenCalledWith(true); expect(view.render).toHaveBeenCalledWith(true);
}); });
@ -106,6 +105,7 @@
beforeEach(function() { beforeEach(function() {
spyOn(serverView, "render"); spyOn(serverView, "render");
spyOn(coordinatorView, "render");
view = new window.ClusterOverviewView(); view = new window.ClusterOverviewView();
// Fake Data Injection to be removed // Fake Data Injection to be removed
view.fakeData = { view.fakeData = {
@ -132,6 +132,10 @@
expect(serverView.render).not.toHaveBeenCalled(); expect(serverView.render).not.toHaveBeenCalled();
}); });
it("should not render the Coordinator view", function() {
expect(coordinatorView.render).not.toHaveBeenCalled();
});
it("should render in minified version", function() { it("should render in minified version", function() {
expect($(div).hasClass("clusterColumnMax")).toBeFalsy(); expect($(div).hasClass("clusterColumnMax")).toBeFalsy();
}); });
@ -253,10 +257,10 @@
view.fakeData.dbservers.having = 4; view.fakeData.dbservers.having = 4;
view.render(); view.render();
var tile = getTile(), var tile = getTile(),
spans = $("> span", $(tile)), headers = $("> h4", $(tile)),
header = spans[0], header = headers[0],
icon = spans[1], footer = headers[1],
footer = $("> div", $(tile)), icon = $("> div > span", $(tile))[0],
htxt = $(header).text(), htxt = $(header).text(),
ftxt = $(footer).text(); ftxt = $(footer).text();
expect(tile).toBeDefined(); expect(tile).toBeDefined();
@ -304,10 +308,10 @@
view.fakeData.coordinators.having = 4; view.fakeData.coordinators.having = 4;
view.render(); view.render();
var tile = getTile(), var tile = getTile(),
spans = $("> span", $(tile)), headers = $("> h4", $(tile)),
header = spans[0], header = headers[0],
icon = spans[1], footer = headers[1],
footer = $("> div", $(tile)), icon = $("> div > span", $(tile))[0],
htxt = $(header).text(), htxt = $(header).text(),
ftxt = $(footer).text(); ftxt = $(footer).text();
expect(tile).toBeDefined(); expect(tile).toBeDefined();