1
0
Fork 0

Wired Coordinators to backend

This commit is contained in:
Michael Hackstein 2014-01-21 16:29:18 +01:00
parent 7e732174ce
commit 8d48855875
4 changed files with 68 additions and 27 deletions

View File

@ -70,6 +70,25 @@
res.json(resList);
});
controller.get("/Coordinators", function(req, res) {
var resList = [],
list = coords.getList(),
noBeat = beats.noBeat();
_.each(list, function(url, k) {
var v = {};
v.name = k;
v.url = url;
resList.push(v);
if (_.contains(noBeat, k)) {
v.status = "critical";
return;
}
v.status = "ok";
});
res.json(resList);
});
controller.get("/Databases", function(req, res) {
var list = dbs.getList();
res.json(_.map(list, function(d) {

View File

@ -8,32 +8,47 @@
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"
}
];
this.fetch({
async: false
});
return this.map(function(m) {
return m.forList();
});
},
getOverview: function() {
// Fake data
return {
plan: 3,
having: 2,
status: "critical"
this.fetch({
async: false
});
var res = {
plan: 0,
having: 0,
status: "ok"
},
updateStatus = function(to) {
if (res.status === "critical") {
return;
}
res.status = to;
};
this.each(function(m) {
res.plan++;
switch (m.get("status")) {
case "ok":
res.having++;
break;
case "warning":
res.having++;
updateStatus("warning");
break;
case "critical":
updateStatus("critical");
break;
default:
console.debug("Undefined server state occured. This is still in development");
}
});
return res;
}
});

View File

@ -6,11 +6,10 @@
window.ClusterCollection = Backbone.Model.extend({
defaults: {
"name": "",
"id": "",
"status": "ok"
},
idAttribute: "id",
idAttribute: "name",
forList: function() {
return {

View File

@ -4,15 +4,23 @@
"use strict";
window.ClusterCoordinator = Backbone.Model.extend({
defaults: {
"name": "",
"url": ""
"url": "",
"status": "ok"
},
idAttribute: "name",
url: function() {
return "/_admin/aardvark/cluster/Coordinators";
url: "/_admin/aardvark/cluster/Coordinators",
forList: function() {
return {
name: this.get("name"),
status: this.get("status"),
url: this.get("url")
};
}
});