mirror of https://gitee.com/bigwinds/arangodb
Wired Coordinators to backend
This commit is contained in:
parent
7e732174ce
commit
8d48855875
|
@ -70,6 +70,25 @@
|
||||||
res.json(resList);
|
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) {
|
controller.get("/Databases", function(req, res) {
|
||||||
var list = dbs.getList();
|
var list = dbs.getList();
|
||||||
res.json(_.map(list, function(d) {
|
res.json(_.map(list, function(d) {
|
||||||
|
|
|
@ -8,32 +8,47 @@
|
||||||
url: "/_admin/aardvark/cluster/Coordinators",
|
url: "/_admin/aardvark/cluster/Coordinators",
|
||||||
|
|
||||||
getList: function() {
|
getList: function() {
|
||||||
return [
|
this.fetch({
|
||||||
{
|
async: false
|
||||||
name: "Charly",
|
});
|
||||||
url: "tcp://192.168.0.1:1337",
|
return this.map(function(m) {
|
||||||
status: "ok"
|
return m.forList();
|
||||||
},
|
});
|
||||||
{
|
|
||||||
name: "Carlos",
|
|
||||||
url: "tcp://192.168.0.2:1337",
|
|
||||||
status: "critical"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Chantalle",
|
|
||||||
url: "tcp://192.168.0.5:1337",
|
|
||||||
status: "ok"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getOverview: function() {
|
getOverview: function() {
|
||||||
// Fake data
|
this.fetch({
|
||||||
return {
|
async: false
|
||||||
plan: 3,
|
});
|
||||||
having: 2,
|
var res = {
|
||||||
status: "critical"
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,11 +6,10 @@
|
||||||
window.ClusterCollection = Backbone.Model.extend({
|
window.ClusterCollection = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
"name": "",
|
"name": "",
|
||||||
"id": "",
|
|
||||||
"status": "ok"
|
"status": "ok"
|
||||||
},
|
},
|
||||||
|
|
||||||
idAttribute: "id",
|
idAttribute: "name",
|
||||||
|
|
||||||
forList: function() {
|
forList: function() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,15 +4,23 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
window.ClusterCoordinator = Backbone.Model.extend({
|
window.ClusterCoordinator = Backbone.Model.extend({
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
"name": "",
|
"name": "",
|
||||||
"url": ""
|
"url": "",
|
||||||
|
"status": "ok"
|
||||||
},
|
},
|
||||||
|
|
||||||
idAttribute: "name",
|
idAttribute: "name",
|
||||||
|
|
||||||
url: function() {
|
url: "/_admin/aardvark/cluster/Coordinators",
|
||||||
return "/_admin/aardvark/cluster/Coordinators";
|
|
||||||
|
forList: function() {
|
||||||
|
return {
|
||||||
|
name: this.get("name"),
|
||||||
|
status: this.get("status"),
|
||||||
|
url: this.get("url")
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue