2016-06-23 17:31:39 +02:00
|
|
|
function send(method,url,data) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
var req = new XMLHttpRequest();
|
|
|
|
req.open(method, url);
|
|
|
|
|
|
|
|
req.onload = function() {
|
|
|
|
if (req.status == 200) {
|
|
|
|
resolve(req.response);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
req.onerror = function() {
|
|
|
|
reject(Error("Network Error"));
|
|
|
|
};
|
|
|
|
|
|
|
|
if(data){
|
|
|
|
req.send(JSON.stringify(data));
|
|
|
|
}else{
|
|
|
|
req.send();
|
|
|
|
}
|
2016-07-01 08:25:32 +02:00
|
|
|
}).then(function(data){
|
|
|
|
if(data[0]=='{')
|
2016-07-01 16:01:28 +02:00
|
|
|
return JSON.parse(data);
|
|
|
|
return data;
|
2016-07-01 08:25:32 +02:00
|
|
|
});
|
2016-06-23 17:31:39 +02:00
|
|
|
}
|
|
|
|
function localStorageTest() {
|
2016-07-01 16:01:28 +02:00
|
|
|
var test = 'test';
|
2016-06-23 17:31:39 +02:00
|
|
|
try {
|
2016-07-01 16:01:28 +02:00
|
|
|
localStorage.setItem(test, test);
|
|
|
|
localStorage.removeItem(test);
|
|
|
|
return true;
|
2016-06-23 17:31:39 +02:00
|
|
|
} catch(e) {
|
2016-07-01 16:01:28 +02:00
|
|
|
return false;
|
2016-06-23 17:31:39 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 03:17:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
function sshUrl(nodeid){
|
|
|
|
if(internal.nodes[nodeid]){
|
2016-07-01 16:01:28 +02:00
|
|
|
node = internal.nodes[nodeid];
|
|
|
|
ip ='z-';
|
2016-06-24 03:17:12 +02:00
|
|
|
for(var i=0;i<node.nodeinfo.network.addresses.length;i++){
|
|
|
|
if(ip[0]> node.nodeinfo.network.addresses[i][0])
|
2016-07-01 16:01:28 +02:00
|
|
|
ip = node.nodeinfo.network.addresses[i];
|
2016-06-24 03:17:12 +02:00
|
|
|
}
|
2016-07-01 16:01:28 +02:00
|
|
|
return '<a href="ssh://root@['+ip+']">SSH</a>';
|
2016-06-24 03:17:12 +02:00
|
|
|
}
|
2016-07-01 16:01:28 +02:00
|
|
|
return '';
|
2016-06-24 03:17:12 +02:00
|
|
|
}
|