1
0
Fork 0

Added first version of Cluster collection overview

This commit is contained in:
Michael Hackstein 2014-01-17 09:24:46 +01:00
parent 7b37f6840d
commit 1a233fb1d5
4 changed files with 116 additions and 42 deletions

View File

@ -1,4 +1,19 @@
<% var statusClass = function(s) {
switch (s) {
case "ok":
return "success";
case "warning":
return "warning";
case "critical":
return "danger";
}
};
%>
<h3 class="clusterColumnHeader">Collections</h3> <h3 class="clusterColumnHeader">Collections</h3>
<button id="Documents" class="collection">Documents</button> <ul>
<button id="Edges" class="collection">Edges</button> <% _.each(collections, function(v) { %>
<button id="People" class="collection">People</button> <li>
<button id="<%=v.name%>" class="btn btn-server btn-<%=statusClass(v.status) %> collection"><%=v.name %></button>
</li>
<% }); %>
</ul>

View File

@ -16,6 +16,22 @@
initialize: function() { initialize: function() {
this.shardsView = new window.ClusterShardsView(); this.shardsView = new window.ClusterShardsView();
this.fakeData = {
collections: [
{
name: "Documents",
status: "ok"
},
{
name: "Edges",
status: "warning"
},
{
name: "People",
status: "critical"
}
]
};
}, },
loadCollection: function(e) { loadCollection: function(e) {
@ -26,7 +42,9 @@
}, },
render: function(){ render: function(){
$(this.el).html(this.template.render({})); $(this.el).html(this.template.render({
collections: this.fakeData.collections
}));
return this; return this;
} }

View File

@ -1,7 +1,7 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/ /*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
/*global describe, beforeEach, afterEach, it, */ /*global describe, beforeEach, afterEach, it, */
/*global spyOn, expect*/ /*global spyOn, expect*/
/*global templateEngine, $*/ /*global templateEngine, $, uiMatchers*/
(function() { (function() {
"use strict"; "use strict";
@ -16,6 +16,7 @@
render: function(){} render: function(){}
}; };
spyOn(window, "ClusterShardsView").andReturn(shardsView); spyOn(window, "ClusterShardsView").andReturn(shardsView);
uiMatchers.define(this);
}); });
afterEach(function() { afterEach(function() {
@ -33,24 +34,62 @@
describe("rendering", function() { describe("rendering", function() {
var docs, edges, people, colls,
checkButtonContent = function(col, cls) {
var btn = document.getElementById(col.name);
expect(btn).toBeOfClass("btn");
expect(btn).toBeOfClass("btn-server");
expect(btn).toBeOfClass("collection");
expect(btn).toBeOfClass("btn-" + cls);
expect($(btn).text()).toEqual(col.name);
};
beforeEach(function() { beforeEach(function() {
docs = {
name: "Documents",
status: "ok"
};
edges = {
name: "Edges",
status: "warning"
};
people = {
name: "People",
status: "critical"
};
colls = [
docs,
edges,
people
];
spyOn(shardsView, "render"); spyOn(shardsView, "render");
view = new window.ClusterCollectionView(); view = new window.ClusterCollectionView();
view.fakeData.collections = colls;
view.render();
}); });
it("should not render the Server view", function() { it("should not render the server view", function() {
view.render();
expect(shardsView.render).not.toHaveBeenCalled(); expect(shardsView.render).not.toHaveBeenCalled();
}); });
it("should render the documents collection", function() {
checkButtonContent(docs, "success");
});
it("should render the edge collection", function() {
checkButtonContent(edges, "warning");
});
it("should render the people collection", function() {
checkButtonContent(people, "danger");
}); });
describe("user actions", function() { describe("user actions", function() {
var info; var info;
beforeEach(function() { beforeEach(function() {
spyOn(shardsView, "render");
view = new window.ClusterCollectionView(); view = new window.ClusterCollectionView();
view.render();
}); });
it("should be able to navigate to Documents", function() { it("should be able to navigate to Documents", function() {
@ -78,6 +117,8 @@
}); });
}); });
});
}); });