mirror of https://gitee.com/bigwinds/arangodb
Added first version of Cluster collection overview
This commit is contained in:
parent
7b37f6840d
commit
1a233fb1d5
|
@ -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>
|
||||
<button id="Documents" class="collection">Documents</button>
|
||||
<button id="Edges" class="collection">Edges</button>
|
||||
<button id="People" class="collection">People</button>
|
||||
<ul>
|
||||
<% _.each(collections, function(v) { %>
|
||||
<li>
|
||||
<button id="<%=v.name%>" class="btn btn-server btn-<%=statusClass(v.status) %> collection"><%=v.name %></button>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
|
|
|
@ -16,6 +16,22 @@
|
|||
|
||||
initialize: function() {
|
||||
this.shardsView = new window.ClusterShardsView();
|
||||
this.fakeData = {
|
||||
collections: [
|
||||
{
|
||||
name: "Documents",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Edges",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "People",
|
||||
status: "critical"
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
|
||||
loadCollection: function(e) {
|
||||
|
@ -26,7 +42,9 @@
|
|||
},
|
||||
|
||||
render: function(){
|
||||
$(this.el).html(this.template.render({}));
|
||||
$(this.el).html(this.template.render({
|
||||
collections: this.fakeData.collections
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
|
||||
/*global describe, beforeEach, afterEach, it, */
|
||||
/*global spyOn, expect*/
|
||||
/*global templateEngine, $*/
|
||||
/*global templateEngine, $, uiMatchers*/
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
|||
render: function(){}
|
||||
};
|
||||
spyOn(window, "ClusterShardsView").andReturn(shardsView);
|
||||
uiMatchers.define(this);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
@ -33,24 +34,62 @@
|
|||
|
||||
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() {
|
||||
docs = {
|
||||
name: "Documents",
|
||||
status: "ok"
|
||||
};
|
||||
edges = {
|
||||
name: "Edges",
|
||||
status: "warning"
|
||||
};
|
||||
people = {
|
||||
name: "People",
|
||||
status: "critical"
|
||||
};
|
||||
colls = [
|
||||
docs,
|
||||
edges,
|
||||
people
|
||||
];
|
||||
spyOn(shardsView, "render");
|
||||
view = new window.ClusterCollectionView();
|
||||
view.fakeData.collections = colls;
|
||||
view.render();
|
||||
});
|
||||
|
||||
it("should not render the Server view", function() {
|
||||
view.render();
|
||||
it("should not render the server view", function() {
|
||||
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() {
|
||||
var info;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(shardsView, "render");
|
||||
view = new window.ClusterCollectionView();
|
||||
view.render();
|
||||
});
|
||||
|
||||
it("should be able to navigate to Documents", function() {
|
||||
|
@ -78,6 +117,8 @@
|
|||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue