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>
|
<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>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<% _.each(databases, function(v) { %>
|
<% _.each(databases, function(v) { %>
|
||||||
<li>
|
<li>
|
||||||
<button id="<%=v.name %>" class="btn btn-server btn-<%=statusClass(v.status)%> database"><%=v.name %></button>
|
<button id="<%=v.name %>" class="btn btn-server btn-<%=statusClass(v.status)%> database"><%=v.name %></button>
|
||||||
</li>
|
</li>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,51 +34,91 @@
|
||||||
|
|
||||||
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() {
|
||||||
|
var info;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
view = new window.ClusterCollectionView();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be able to navigate to Documents", function() {
|
||||||
|
info = {
|
||||||
|
name: "Documents"
|
||||||
|
};
|
||||||
|
$("#Documents").click();
|
||||||
|
expect(shardsView.render).toHaveBeenCalledWith(info);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be able to navigate to Edges", function() {
|
||||||
|
info = {
|
||||||
|
name: "Edges"
|
||||||
|
};
|
||||||
|
$("#Edges").click();
|
||||||
|
expect(shardsView.render).toHaveBeenCalledWith(info);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be able to navigate to People", function() {
|
||||||
|
info = {
|
||||||
|
name: "People"
|
||||||
|
};
|
||||||
|
$("#People").click();
|
||||||
|
expect(shardsView.render).toHaveBeenCalledWith(info);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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() {
|
|
||||||
info = {
|
|
||||||
name: "Documents"
|
|
||||||
};
|
|
||||||
$("#Documents").click();
|
|
||||||
expect(shardsView.render).toHaveBeenCalledWith(info);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should be able to navigate to Edges", function() {
|
|
||||||
info = {
|
|
||||||
name: "Edges"
|
|
||||||
};
|
|
||||||
$("#Edges").click();
|
|
||||||
expect(shardsView.render).toHaveBeenCalledWith(info);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should be able to navigate to People", function() {
|
|
||||||
info = {
|
|
||||||
name: "People"
|
|
||||||
};
|
|
||||||
$("#People").click();
|
|
||||||
expect(shardsView.render).toHaveBeenCalledWith(info);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue