mirror of https://gitee.com/bigwinds/arangodb
Created Models and Collections for cluster objects. These return fake data right now, but make wiring to foxx a lot easier
This commit is contained in:
parent
6a002416d2
commit
a0cb9d832f
|
@ -0,0 +1,31 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.ClusterCollections = Backbone.Collection.extend({
|
||||
model: window.ClusterCollection,
|
||||
|
||||
url: "/_admin/aardvark/cluster/Collections",
|
||||
|
||||
getList: function() {
|
||||
return [
|
||||
{
|
||||
name: "Documents",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Edges",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "People",
|
||||
status: "critical"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.ClusterCoordinators = Backbone.Collection.extend({
|
||||
model: window.ClusterCoordinator,
|
||||
|
||||
url: "/_admin/aardvark/cluster/Coordinators",
|
||||
|
||||
getList: function() {
|
||||
return [
|
||||
{
|
||||
name: "Charly",
|
||||
url: "tcp://192.168.0.1:1337",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Carlos",
|
||||
url: "tcp://192.168.0.2:1337",
|
||||
status: "critical"
|
||||
},
|
||||
{
|
||||
name: "Chantalle",
|
||||
url: "tcp://192.168.0.5:1337",
|
||||
status: "ok"
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
getOverview: function() {
|
||||
// Fake data
|
||||
return {
|
||||
plan: 3,
|
||||
having: 2,
|
||||
status: "critical"
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.ClusterDatabases = Backbone.Collection.extend({
|
||||
model: window.ClusterDatabase,
|
||||
|
||||
url: "/_admin/aardvark/cluster/Databases",
|
||||
|
||||
getList: function() {
|
||||
return [
|
||||
{
|
||||
name: "_system",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "myDatabase",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "otherDatabase",
|
||||
status: "critical"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.ClusterServers = Backbone.Collection.extend({
|
||||
model: window.ClusterServer,
|
||||
|
||||
url: "/_admin/aardvark/cluster/DBServers",
|
||||
|
||||
getList: function() {
|
||||
return [
|
||||
{
|
||||
primary: {
|
||||
name: "Pavel",
|
||||
url: "tcp://192.168.0.1:1337",
|
||||
status: "ok"
|
||||
},
|
||||
secondary: {
|
||||
name: "Sally",
|
||||
url: "tcp://192.168.1.1:1337",
|
||||
status: "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
primary: {
|
||||
name: "Pancho",
|
||||
url: "tcp://192.168.0.2:1337",
|
||||
status: "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
primary: {
|
||||
name: "Pablo",
|
||||
url: "tcp://192.168.0.5:1337",
|
||||
status: "critical"
|
||||
},
|
||||
secondary: {
|
||||
name: "Sandy",
|
||||
url: "tcp://192.168.1.5:1337",
|
||||
status: "critical"
|
||||
}
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
getOverview: function() {
|
||||
// Fake data
|
||||
return {
|
||||
plan: 3,
|
||||
having: 3,
|
||||
status: "warning"
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
window.ClusterShards = Backbone.Collection.extend({
|
||||
model: window.ClusterShard,
|
||||
|
||||
url: "/_admin/aardvark/cluster/Shards",
|
||||
|
||||
getList: function() {
|
||||
return [
|
||||
{
|
||||
name: "Shard 1",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Shard 2",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "Shard 3",
|
||||
status: "critical"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.ClusterDatabase = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"name": "",
|
||||
"id": ""
|
||||
},
|
||||
|
||||
idAttribute: "id",
|
||||
|
||||
url: function() {
|
||||
return "/_admin/aardvark/cluster/Collections";
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.ClusterCoordinator = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"name": "",
|
||||
"url": ""
|
||||
},
|
||||
|
||||
idAttribute: "name",
|
||||
|
||||
url: function() {
|
||||
return "/_admin/aardvark/cluster/Coordinators";
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
|
@ -0,0 +1,18 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.ClusterDatabase = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"name": ""
|
||||
},
|
||||
|
||||
idAttribute: "name",
|
||||
|
||||
url: function() {
|
||||
return "/_admin/aardvark/cluster/Databases";
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
|
@ -0,0 +1,20 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.ClusterServer = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"name": "",
|
||||
"url": ""
|
||||
},
|
||||
|
||||
idAttribute: "name",
|
||||
|
||||
url: function() {
|
||||
return "/_admin/aardvark/cluster/DBServers";
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone */
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.ClusterShard = Backbone.Model.extend({
|
||||
defaults: {
|
||||
"id": ""
|
||||
},
|
||||
|
||||
idAttribute: "id",
|
||||
|
||||
url: function() {
|
||||
return "/_admin/aardvark/cluster/Shards";
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
@ -15,23 +15,9 @@
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.shardsView = new window.ClusterShardsView();
|
||||
this.fakeData = {
|
||||
collections: [
|
||||
{
|
||||
name: "Documents",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Edges",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "People",
|
||||
status: "critical"
|
||||
}
|
||||
]
|
||||
};
|
||||
this.shardsView = new window.ClusterShardsView({
|
||||
collection: new window.ClusterShards()
|
||||
});
|
||||
},
|
||||
|
||||
loadCollection: function(e) {
|
||||
|
@ -48,7 +34,7 @@
|
|||
|
||||
render: function() {
|
||||
$(this.el).html(this.template.render({
|
||||
collections: this.fakeData.collections
|
||||
collections: this.collection.getList()
|
||||
}));
|
||||
this.shardsView.unrender();
|
||||
return this;
|
||||
|
|
|
@ -11,25 +11,6 @@
|
|||
template: templateEngine.createTemplate("clusterCoordinatorView.ejs"),
|
||||
|
||||
initialize: function() {
|
||||
this.fakeData = {
|
||||
coordinators: [
|
||||
{
|
||||
name: "Charly",
|
||||
url: "tcp://192.168.0.1:1337",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Carlos",
|
||||
url: "tcp://192.168.0.2:1337",
|
||||
status: "critical"
|
||||
},
|
||||
{
|
||||
name: "Chantalle",
|
||||
url: "tcp://192.168.0.5:1337",
|
||||
status: "ok"
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
|
||||
unrender: function() {
|
||||
|
@ -38,7 +19,7 @@
|
|||
|
||||
render: function() {
|
||||
$(this.el).html(this.template.render({
|
||||
coordinators: this.fakeData.coordinators
|
||||
coordinators: this.collection.getList()
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -10,9 +10,17 @@
|
|||
|
||||
template: templateEngine.createTemplate("clusterDashboardView.ejs"),
|
||||
|
||||
initialize: function() {
|
||||
this.dbservers = new window.ClusterServers();
|
||||
this.coordinators = new window.ClusterCoordinators();
|
||||
},
|
||||
|
||||
render: function(){
|
||||
$(this.el).html(this.template.render({}));
|
||||
this.overView = new window.ClusterOverviewView();
|
||||
this.overView = new window.ClusterOverviewView({
|
||||
dbservers: this.dbservers,
|
||||
coordinators: this.coordinators
|
||||
});
|
||||
this.overView.render();
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -15,23 +15,9 @@
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.colView = new window.ClusterCollectionView();
|
||||
this.fakeData = {
|
||||
databases: [
|
||||
{
|
||||
name: "_system",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "myDatabase",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "otherDatabase",
|
||||
status: "critical"
|
||||
}
|
||||
]
|
||||
};
|
||||
this.colView = new window.ClusterCollectionView({
|
||||
collection: new window.ClusterCollections()
|
||||
});
|
||||
},
|
||||
|
||||
loadDatabase: function(e) {
|
||||
|
@ -46,7 +32,7 @@
|
|||
|
||||
render: function(){
|
||||
$(this.el).html(this.template.render({
|
||||
databases: this.fakeData.databases
|
||||
databases: this.collection.getList()
|
||||
}));
|
||||
this.colView.unrender();
|
||||
return this;
|
||||
|
|
|
@ -16,21 +16,14 @@
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.fakeData = {
|
||||
dbservers: {
|
||||
plan: 3,
|
||||
having: 3,
|
||||
status: "warning"
|
||||
},
|
||||
coordinators: {
|
||||
plan: 3,
|
||||
having: 2,
|
||||
status: "critical"
|
||||
}
|
||||
};
|
||||
|
||||
this.serverView = new window.ClusterServerView();
|
||||
this.coordinatorView = new window.ClusterCoordinatorView();
|
||||
this.dbservers = this.options.dbservers;
|
||||
this.coordinators = this.options.coordinators;
|
||||
this.serverView = new window.ClusterServerView({
|
||||
collection: this.dbservers
|
||||
});
|
||||
this.coordinatorView = new window.ClusterCoordinatorView({
|
||||
collection: this.coordinators
|
||||
});
|
||||
},
|
||||
|
||||
loadDBServers: function() {
|
||||
|
@ -48,8 +41,8 @@
|
|||
render: function(minify){
|
||||
$(this.el).html(this.template.render({
|
||||
minify: minify,
|
||||
dbservers: this.fakeData.dbservers,
|
||||
coordinators: this.fakeData.coordinators
|
||||
dbservers: this.dbservers.getOverview(),
|
||||
coordinators: this.coordinators.getOverview()
|
||||
}));
|
||||
$(this.el).toggleClass("clusterColumnMax", !minify);
|
||||
return this;
|
||||
|
|
|
@ -15,41 +15,9 @@
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.dbView = new window.ClusterDatabaseView();
|
||||
|
||||
this.fakeData = [
|
||||
{
|
||||
primary: {
|
||||
name: "Pavel",
|
||||
url: "tcp://192.168.0.1:1337",
|
||||
status: "ok"
|
||||
},
|
||||
secondary: {
|
||||
name: "Sally",
|
||||
url: "tcp://192.168.1.1:1337",
|
||||
status: "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
primary: {
|
||||
name: "Pancho",
|
||||
url: "tcp://192.168.0.2:1337",
|
||||
status: "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
primary: {
|
||||
name: "Pablo",
|
||||
url: "tcp://192.168.0.5:1337",
|
||||
status: "critical"
|
||||
},
|
||||
secondary: {
|
||||
name: "Sandy",
|
||||
url: "tcp://192.168.1.5:1337",
|
||||
status: "critical"
|
||||
}
|
||||
}
|
||||
];
|
||||
this.dbView = new window.ClusterDatabaseView({
|
||||
collection: new window.ClusterDatabases()
|
||||
});
|
||||
},
|
||||
|
||||
loadServer: function(e) {
|
||||
|
@ -71,7 +39,7 @@
|
|||
}
|
||||
$(this.el).html(this.template.render({
|
||||
minify: minify,
|
||||
servers: this.fakeData
|
||||
servers: this.collection.getList()
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -10,32 +10,13 @@
|
|||
|
||||
template: templateEngine.createTemplate("clusterShardsView.ejs"),
|
||||
|
||||
initialize: function() {
|
||||
this.fakeData = {
|
||||
shards: [
|
||||
{
|
||||
name: "Shard 1",
|
||||
status: "ok"
|
||||
},
|
||||
{
|
||||
name: "Shard 2",
|
||||
status: "warning"
|
||||
},
|
||||
{
|
||||
name: "Shard 3",
|
||||
status: "critical"
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
|
||||
unrender: function() {
|
||||
$(this.el).html("");
|
||||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).html(this.template.render({
|
||||
shards: this.fakeData.shards
|
||||
shards: this.collection.getList()
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -127,6 +127,11 @@ module.exports = function(karma) {
|
|||
'frontend/js/models/arangoStatisticsDescription.js',
|
||||
'frontend/js/models/foxx.js',
|
||||
'frontend/js/models/graph.js',
|
||||
'frontend/js/models/clusterServer.js',
|
||||
'frontend/js/models/clusterCoordinator.js',
|
||||
'frontend/js/models/clusterDatabase.js',
|
||||
'frontend/js/models/clusterCollection.js',
|
||||
'frontend/js/models/clusterShard.js',
|
||||
|
||||
// Collections
|
||||
'frontend/js/collections/arangoCollections.js',
|
||||
|
@ -139,6 +144,11 @@ module.exports = function(karma) {
|
|||
'frontend/js/collections/arangoStatisticsDescriptionCollection.js',
|
||||
'frontend/js/collections/foxxCollection.js',
|
||||
'frontend/js/collections/graphCollection.js',
|
||||
'frontend/js/collections/clusterServers.js',
|
||||
'frontend/js/collections/clusterCoordinators.js',
|
||||
'frontend/js/collections/clusterDatabases.js',
|
||||
'frontend/js/collections/clusterCollections.js',
|
||||
'frontend/js/collections/clusterShards.js',
|
||||
|
||||
// Views
|
||||
'frontend/js/views/navigationView.js',
|
||||
|
@ -184,7 +194,6 @@ module.exports = function(karma) {
|
|||
//Templates
|
||||
{pattern: 'frontend/js/templates/*.ejs', served:true, included:false, watched: true},
|
||||
// Specs
|
||||
|
||||
// GraphViewer
|
||||
'test/specs/graphViewer/specColourMapper/colourMapperSpec.js',
|
||||
'test/specs/graphViewer/specWindowObjects/domObserverFactorySpec.js',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
describe("Cluster Collection View", function() {
|
||||
var view, div, shardsView;
|
||||
var view, div, shardsView, shardCol;
|
||||
|
||||
beforeEach(function() {
|
||||
div = document.createElement("div");
|
||||
|
@ -16,7 +16,11 @@
|
|||
render: function() {},
|
||||
unrender: function() {}
|
||||
};
|
||||
shardCol = {
|
||||
__refId: "testId"
|
||||
};
|
||||
spyOn(window, "ClusterShardsView").andReturn(shardsView);
|
||||
spyOn(window, "ClusterShards").andReturn(shardCol);
|
||||
uiMatchers.define(this);
|
||||
});
|
||||
|
||||
|
@ -28,14 +32,17 @@
|
|||
|
||||
it("should create a Cluster Server View", function() {
|
||||
view = new window.ClusterCollectionView();
|
||||
expect(window.ClusterShardsView).toHaveBeenCalled();
|
||||
expect(window.ClusterShards).toHaveBeenCalled();
|
||||
expect(window.ClusterShardsView).toHaveBeenCalledWith({
|
||||
collection: shardCol
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("rendering", function() {
|
||||
|
||||
var docs, edges, people, colls,
|
||||
var docs, edges, people, colls, collCol,
|
||||
checkButtonContent = function(col, cls) {
|
||||
var btn = document.getElementById(col.name);
|
||||
expect(btn).toBeOfClass("btn");
|
||||
|
@ -64,10 +71,16 @@
|
|||
edges,
|
||||
people
|
||||
];
|
||||
collCol = {
|
||||
getList: function() {
|
||||
return colls;
|
||||
}
|
||||
};
|
||||
spyOn(shardsView, "render");
|
||||
spyOn(shardsView, "unrender");
|
||||
view = new window.ClusterCollectionView();
|
||||
view.fakeData.collections = colls;
|
||||
view = new window.ClusterCollectionView({
|
||||
collection: collCol
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
describe("rendering", function() {
|
||||
|
||||
var charly, carlos, chantalle, coordinators,
|
||||
coordCol,
|
||||
getTile = function(name) {
|
||||
return document.getElementById(name);
|
||||
},
|
||||
|
@ -38,7 +39,6 @@
|
|||
};
|
||||
|
||||
beforeEach(function() {
|
||||
view = new window.ClusterCoordinatorView();
|
||||
charly = {
|
||||
name: "Charly",
|
||||
url: "tcp://192.168.0.1:1337",
|
||||
|
@ -59,7 +59,14 @@
|
|||
carlos,
|
||||
chantalle
|
||||
];
|
||||
view.fakeData.coordinators = coordinators;
|
||||
coordCol = {
|
||||
getList: function() {
|
||||
return coordinators;
|
||||
}
|
||||
};
|
||||
view = new window.ClusterCoordinatorView({
|
||||
collection: coordCol
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
|
|
|
@ -22,28 +22,61 @@
|
|||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
describe("rendering", function() {
|
||||
var info;
|
||||
describe("initialisation", function() {
|
||||
|
||||
var servCol, coorCol;
|
||||
|
||||
beforeEach(function() {
|
||||
servCol = {
|
||||
__id: "servId"
|
||||
};
|
||||
coorCol = {
|
||||
__id: "coorId"
|
||||
};
|
||||
spyOn(overview, "render");
|
||||
spyOn(window, "ClusterServers").andReturn(servCol);
|
||||
spyOn(window, "ClusterCoordinators").andReturn(coorCol);
|
||||
view = new window.ClusterDashboardView();
|
||||
});
|
||||
|
||||
it("should create a Cluster Overview View", function() {
|
||||
expect(window.ClusterOverviewView).not.toHaveBeenCalled();
|
||||
window.ClusterOverviewView.reset();
|
||||
view.render();
|
||||
expect(window.ClusterOverviewView).toHaveBeenCalled();
|
||||
window.ClusterOverviewView.reset();
|
||||
view.render();
|
||||
expect(window.ClusterOverviewView).toHaveBeenCalled();
|
||||
it("should create the cluster server collection", function() {
|
||||
expect(window.ClusterServers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should render the Cluster Overview", function() {
|
||||
view.render();
|
||||
expect(overview.render).toHaveBeenCalled();
|
||||
it("should create the cluster coordinators collection", function() {
|
||||
expect(window.ClusterCoordinators).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("rendering", function() {
|
||||
var info;
|
||||
|
||||
beforeEach(function() {
|
||||
window.ClusterServers.reset();
|
||||
window.ClusterCoordinators.reset();
|
||||
});
|
||||
|
||||
it("should create a Cluster Overview View", function() {
|
||||
expect(window.ClusterOverviewView).not.toHaveBeenCalled();
|
||||
expect(window.ClusterServers).not.toHaveBeenCalled();
|
||||
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
|
||||
window.ClusterOverviewView.reset();
|
||||
view.render();
|
||||
expect(window.ClusterOverviewView).toHaveBeenCalled();
|
||||
expect(window.ClusterServers).not.toHaveBeenCalled();
|
||||
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
|
||||
window.ClusterOverviewView.reset();
|
||||
view.render();
|
||||
expect(window.ClusterOverviewView).toHaveBeenCalled();
|
||||
expect(window.ClusterServers).not.toHaveBeenCalled();
|
||||
expect(window.ClusterCoordinators).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should render the Cluster Overview", function() {
|
||||
view.render();
|
||||
expect(overview.render).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
describe("Cluster Database View", function() {
|
||||
var view, div, colView;
|
||||
var view, div, colView, colCol;
|
||||
|
||||
beforeEach(function() {
|
||||
div = document.createElement("div");
|
||||
|
@ -16,7 +16,11 @@
|
|||
render: function() {},
|
||||
unrender: function() {}
|
||||
};
|
||||
colCol = {
|
||||
__id: "refId"
|
||||
};
|
||||
spyOn(window, "ClusterCollectionView").andReturn(colView);
|
||||
spyOn(window, "ClusterCollections").andReturn(colCol);
|
||||
uiMatchers.define(this);
|
||||
});
|
||||
|
||||
|
@ -27,15 +31,20 @@
|
|||
describe("initialisation", function() {
|
||||
|
||||
it("should create a Cluster Collection View", function() {
|
||||
view = new window.ClusterDatabaseView();
|
||||
expect(window.ClusterCollectionView).toHaveBeenCalled();
|
||||
view = new window.ClusterDatabaseView({
|
||||
collection: {}
|
||||
});
|
||||
expect(window.ClusterCollections).toHaveBeenCalled();
|
||||
expect(window.ClusterCollectionView).toHaveBeenCalledWith({
|
||||
collection: colCol
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("rendering", function() {
|
||||
|
||||
var db1, db2, db3, databases,
|
||||
var db1, db2, db3, databases, dbCol,
|
||||
checkButtonContent = function(db, cls) {
|
||||
var btn = document.getElementById(db.name);
|
||||
expect(btn).toBeOfClass("btn");
|
||||
|
@ -66,8 +75,14 @@
|
|||
db2,
|
||||
db3
|
||||
];
|
||||
view = new window.ClusterDatabaseView();
|
||||
view.fakeData.databases = databases;
|
||||
dbCol = {
|
||||
getList: function() {
|
||||
return databases;
|
||||
}
|
||||
};
|
||||
view = new window.ClusterDatabaseView({
|
||||
collection: dbCol
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
"use strict";
|
||||
|
||||
describe("Cluster Overview View", function() {
|
||||
var view, div, serverView, coordinatorView;
|
||||
var view, div, serverView, coordinatorView,
|
||||
clusterServers, serverStatus,
|
||||
serverHaving, serverPlan,
|
||||
clusterCoordinators, coordinatorStatus,
|
||||
coordinatorHaving, coordinatorPlan;
|
||||
|
||||
beforeEach(function() {
|
||||
div = document.createElement("div");
|
||||
|
@ -20,6 +24,30 @@
|
|||
render: function() {},
|
||||
unrender: function() {}
|
||||
};
|
||||
serverStatus = "warning";
|
||||
serverHaving = 3;
|
||||
serverPlan = 3;
|
||||
clusterServers = {
|
||||
getOverview: function() {
|
||||
return {
|
||||
plan: serverPlan,
|
||||
having: serverHaving,
|
||||
status: serverStatus
|
||||
};
|
||||
}
|
||||
};
|
||||
coordinatorStatus = "critical";
|
||||
coordinatorHaving = 2;
|
||||
coordinatorPlan = 3;
|
||||
clusterCoordinators = {
|
||||
getOverview: function() {
|
||||
return {
|
||||
plan: coordinatorPlan,
|
||||
having: coordinatorHaving,
|
||||
status: coordinatorStatus
|
||||
};
|
||||
}
|
||||
};
|
||||
spyOn(window, "ClusterServerView").andReturn(serverView);
|
||||
spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView);
|
||||
uiMatchers.define(this);
|
||||
|
@ -32,8 +60,23 @@
|
|||
describe("initialisation", function() {
|
||||
|
||||
it("should create a Cluster Server View", function() {
|
||||
view = new window.ClusterOverviewView();
|
||||
expect(window.ClusterServerView).toHaveBeenCalled();
|
||||
view = new window.ClusterOverviewView({
|
||||
dbservers: clusterServers,
|
||||
coordinators: clusterCoordinators
|
||||
});
|
||||
expect(window.ClusterServerView).toHaveBeenCalledWith({
|
||||
collection: clusterServers
|
||||
});
|
||||
});
|
||||
|
||||
it("should create a Cluster Coordinator View", function() {
|
||||
view = new window.ClusterOverviewView({
|
||||
dbservers: clusterServers,
|
||||
coordinators: clusterCoordinators
|
||||
});
|
||||
expect(window.ClusterCoordinatorView).toHaveBeenCalledWith({
|
||||
collection: clusterCoordinators
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -86,20 +129,10 @@
|
|||
spyOn(serverView, "unrender");
|
||||
spyOn(coordinatorView, "render");
|
||||
spyOn(coordinatorView, "unrender");
|
||||
view = new window.ClusterOverviewView();
|
||||
// Fake Data Injection to be removed
|
||||
view.fakeData = {
|
||||
dbservers: {
|
||||
plan: 3,
|
||||
having: 3,
|
||||
status: "warning"
|
||||
},
|
||||
coordinators: {
|
||||
plan: 3,
|
||||
having: 2,
|
||||
status: "critical"
|
||||
}
|
||||
};
|
||||
view = new window.ClusterOverviewView({
|
||||
dbservers: clusterServers,
|
||||
coordinators: clusterCoordinators
|
||||
});
|
||||
});
|
||||
|
||||
describe("minified version", function() {
|
||||
|
@ -127,8 +160,8 @@
|
|||
};
|
||||
|
||||
it("should render the amounts", function() {
|
||||
view.fakeData.dbservers.plan = 5;
|
||||
view.fakeData.dbservers.having = 4;
|
||||
serverPlan = 5;
|
||||
serverHaving = 4;
|
||||
view.render(true);
|
||||
var btn = getButton(),
|
||||
span = btn.firstChild,
|
||||
|
@ -143,21 +176,21 @@
|
|||
|
||||
it("should render the status ok", function() {
|
||||
var status = "ok";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
||||
it("should render the status warning", function() {
|
||||
var status = "warning";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
||||
it("should render the status critical", function() {
|
||||
var status = "critical";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
@ -171,8 +204,8 @@
|
|||
};
|
||||
|
||||
it("should render the amounts", function() {
|
||||
view.fakeData.coordinators.plan = 5;
|
||||
view.fakeData.coordinators.having = 4;
|
||||
coordinatorPlan = 5;
|
||||
coordinatorHaving = 4;
|
||||
view.render(true);
|
||||
var btn = getButton(),
|
||||
span = btn.firstChild,
|
||||
|
@ -187,21 +220,21 @@
|
|||
|
||||
it("should render the status ok", function() {
|
||||
var status = "ok";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
||||
it("should render the status warning", function() {
|
||||
var status = "warning";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
||||
it("should render the status critical", function() {
|
||||
var status = "critical";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render(true);
|
||||
checkShowStatus(getButton(), status);
|
||||
});
|
||||
|
@ -233,8 +266,8 @@
|
|||
};
|
||||
|
||||
it("should render the tile", function() {
|
||||
view.fakeData.dbservers.plan = 5;
|
||||
view.fakeData.dbservers.having = 4;
|
||||
serverPlan = 5;
|
||||
serverHaving = 4;
|
||||
view.render();
|
||||
var tile = getTile(),
|
||||
headers = $("> h4", $(tile)),
|
||||
|
@ -256,21 +289,21 @@
|
|||
|
||||
it("should render the status ok", function() {
|
||||
var status = "ok";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
||||
it("should render the status warning", function() {
|
||||
var status = "warning";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
||||
it("should render the status critical", function() {
|
||||
var status = "critical";
|
||||
view.fakeData.dbservers.status = status;
|
||||
serverStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
@ -284,8 +317,8 @@
|
|||
};
|
||||
|
||||
it("should render the tile", function() {
|
||||
view.fakeData.coordinators.plan = 5;
|
||||
view.fakeData.coordinators.having = 4;
|
||||
coordinatorPlan = 5;
|
||||
coordinatorHaving = 4;
|
||||
view.render();
|
||||
var tile = getTile(),
|
||||
headers = $("> h4", $(tile)),
|
||||
|
@ -307,21 +340,21 @@
|
|||
|
||||
it("should render the status ok", function() {
|
||||
var status = "ok";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
||||
it("should render the status warning", function() {
|
||||
var status = "warning";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
||||
it("should render the status critical", function() {
|
||||
var status = "critical";
|
||||
view.fakeData.coordinators.status = status;
|
||||
coordinatorStatus = status;
|
||||
view.render();
|
||||
checkShowStatus(getTile(), status);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
describe("Cluster Server View", function() {
|
||||
var view, div, dbView;
|
||||
var view, div, dbView, dbCol;
|
||||
|
||||
beforeEach(function() {
|
||||
div = document.createElement("div");
|
||||
|
@ -16,7 +16,11 @@
|
|||
render: function() {},
|
||||
unrender: function() {}
|
||||
};
|
||||
dbCol = {
|
||||
__id: "testId"
|
||||
};
|
||||
spyOn(window, "ClusterDatabaseView").andReturn(dbView);
|
||||
spyOn(window, "ClusterDatabases").andReturn(dbCol);
|
||||
uiMatchers.define(this);
|
||||
});
|
||||
|
||||
|
@ -28,14 +32,17 @@
|
|||
|
||||
it("should create a Cluster Database View", function() {
|
||||
view = new window.ClusterServerView();
|
||||
expect(window.ClusterDatabaseView).toHaveBeenCalled();
|
||||
expect(window.ClusterDatabaseView).toHaveBeenCalledWith({
|
||||
collection: dbCol
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("rendering", function() {
|
||||
|
||||
var okPair, noBkp, deadBkp, deadPrim, deadPair, fakeServers,
|
||||
var okPair, noBkp, deadBkp, deadPrim, deadPair,
|
||||
fakeServers, dbServers,
|
||||
getTile = function(name) {
|
||||
return document.getElementById(name);
|
||||
},
|
||||
|
@ -79,7 +86,6 @@
|
|||
beforeEach(function() {
|
||||
spyOn(dbView, "render");
|
||||
spyOn(dbView, "unrender");
|
||||
view = new window.ClusterServerView();
|
||||
okPair = {
|
||||
primary: {
|
||||
name: "Pavel",
|
||||
|
@ -141,7 +147,14 @@
|
|||
deadBkp,
|
||||
deadPrim
|
||||
];
|
||||
view.fakeData = fakeServers;
|
||||
dbServers = {
|
||||
getList: function() {
|
||||
return fakeServers;
|
||||
}
|
||||
};
|
||||
view = new window.ClusterServerView({
|
||||
collection: dbServers
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
describe("rendering", function() {
|
||||
|
||||
var s1, s2, s3, shards,
|
||||
var s1, s2, s3, shards, shardCol,
|
||||
checkButtonContent = function(col, cls) {
|
||||
var btn = document.getElementById(col.name);
|
||||
expect(btn).toBeOfClass("btn");
|
||||
|
@ -50,8 +50,14 @@
|
|||
s2,
|
||||
s3
|
||||
];
|
||||
view = new window.ClusterShardsView();
|
||||
view.fakeData.shards = shards;
|
||||
shardCol = {
|
||||
getList: function() {
|
||||
return shards;
|
||||
}
|
||||
};
|
||||
view = new window.ClusterShardsView({
|
||||
collection: shardCol
|
||||
});
|
||||
view.render();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue