2019-03-13 14:18:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function API(baseurl){
|
|
|
|
|
|
2019-03-14 08:36:02 +01:00
|
|
|
|
this.baseurl = baseurl;
|
|
|
|
|
|
|
|
|
|
this.get = function(page, handler = null){
|
|
|
|
|
var x = new XMLHttpRequest();
|
|
|
|
|
var async = (handler != null);
|
|
|
|
|
|
|
|
|
|
if (async)
|
|
|
|
|
{
|
|
|
|
|
x.onload = function(){
|
|
|
|
|
var responseText = x.responseText;
|
|
|
|
|
handler( responseText );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
x.open("GET", this.baseurl + page, async);
|
|
|
|
|
x.send();
|
|
|
|
|
|
|
|
|
|
if (!async)
|
|
|
|
|
return x.responseText
|
|
|
|
|
}
|
|
|
|
|
this.post = function(page, handler = null){
|
|
|
|
|
var x = new XMLHttpRequest();
|
|
|
|
|
if (handler != null)
|
|
|
|
|
{
|
|
|
|
|
x.onload = function(){
|
|
|
|
|
var responseText = x.responseText;
|
|
|
|
|
handler( responseText );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
x.open("POST", this.baseurl + page);
|
|
|
|
|
x.send();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.getJson = function(page, handler){
|
|
|
|
|
var j = function(t){
|
|
|
|
|
handler(JSON.parse(t));
|
|
|
|
|
};
|
|
|
|
|
return this.get( page, j );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.call = function(endpoint,method,parameters = []){
|
|
|
|
|
var x = new XMLHttpRequest();
|
|
|
|
|
x.open("POST", this.baseurl + endpoint, false);
|
|
|
|
|
x.setRequestHeader("content-type","application/json");
|
|
|
|
|
|
|
|
|
|
var methodCall = {
|
|
|
|
|
"MethodName": method,
|
|
|
|
|
"Parameters": parameters
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
x.send(JSON.stringify(methodCall));
|
|
|
|
|
|
|
|
|
|
var result = JSON.parse(x.responseText);
|
|
|
|
|
if (result.Exception != null)
|
|
|
|
|
throw result.Exception;
|
2019-03-13 14:18:05 +01:00
|
|
|
|
|
2019-03-14 08:36:02 +01:00
|
|
|
|
return result.Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2019-03-13 14:18:05 +01:00
|
|
|
|
|
2019-03-14 08:36:02 +01:00
|
|
|
|
function $(id)
|
|
|
|
|
{
|
|
|
|
|
return document.getElementById(id);
|
|
|
|
|
}
|
|
|
|
|
function CE(eName)
|
|
|
|
|
{
|
|
|
|
|
return document.createElement(eName);
|
|
|
|
|
}
|
2019-03-13 14:18:05 +01:00
|
|
|
|
|
|
|
|
|
|
2019-03-14 08:36:02 +01:00
|
|
|
|
var api = null;
|
2019-03-13 14:18:05 +01:00
|
|
|
|
|
|
|
|
|
function loadStatistics()
|
2019-03-14 08:36:02 +01:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var stats = api.call("api/management","GetStatistics");
|
|
|
|
|
|
|
|
|
|
$("indHttpServer").attributes["state"].value = stats.States.HttpServer;
|
|
|
|
|
$("indManager").attributes["state"].value = stats.States.Manager;
|
|
|
|
|
$("indCrawler").attributes["state"].value = stats.States.Crawler;
|
|
|
|
|
$("indChecks").attributes["state"].value = stats.States.Checks;
|
|
|
|
|
$("indDispatcher").attributes["state"].value = stats.States.Dispatcher;
|
|
|
|
|
|
|
|
|
|
} catch (e)
|
|
|
|
|
{
|
|
|
|
|
$("indHttpServer").attributes["state"].value = 3;
|
|
|
|
|
$("indManager").attributes["state"].value = 0;
|
|
|
|
|
$("indCrawler").attributes["state"].value = 0;
|
|
|
|
|
$("indChecks").attributes["state"].value = 0;
|
|
|
|
|
$("indDispatcher").attributes["state"].value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initApi(baseurl)
|
2019-03-13 14:18:05 +01:00
|
|
|
|
{
|
2019-03-14 08:36:02 +01:00
|
|
|
|
api = new API(baseurl);
|
|
|
|
|
setInterval( loadStatistics, 1000 );
|
2019-03-13 14:18:05 +01:00
|
|
|
|
|
2019-03-14 08:36:02 +01:00
|
|
|
|
log("API initialized");
|
2019-03-13 14:18:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|