2014-11-20 20:42:22 +00:00
|
|
|
function getRequest(url, success) {
|
|
|
|
var request = new XMLHttpRequest();
|
|
|
|
request.open('GET', url, true);
|
|
|
|
request.setRequestHeader('Accept', 'application/json');
|
|
|
|
request.onload = function() {
|
|
|
|
if (this.status >= 200 && this.status <= 400) {
|
|
|
|
success(JSON.parse(this.responseText));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
request.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
2014-06-04 20:11:06 +00:00
|
|
|
|
2014-11-20 20:42:22 +00:00
|
|
|
getRequest("/confluent-api/nodes/", function( data) {
|
2014-06-04 20:11:06 +00:00
|
|
|
var items = [];
|
|
|
|
var options = [];
|
|
|
|
var nodename = "";
|
2014-11-20 20:42:22 +00:00
|
|
|
data["_links"]["item"].forEach( function( val, key ) {
|
|
|
|
console.log(val);
|
2014-06-04 20:11:06 +00:00
|
|
|
if (typeof(val) == "object") {
|
|
|
|
nodename = val.href;
|
|
|
|
} else {
|
|
|
|
nodename = val;
|
|
|
|
}
|
2014-11-20 20:42:22 +00:00
|
|
|
console.log(nodename);
|
2014-06-04 20:11:06 +00:00
|
|
|
nodename = nodename.replace('/', '');
|
2014-11-20 20:42:22 +00:00
|
|
|
var myrow = document.createElement('div');
|
|
|
|
myrow.innerHTML = "<button id="+nodename+">"+nodename+"</button><br>";
|
|
|
|
document.getElementById("nodes").appendChild(myrow);
|
|
|
|
document.getElementById(nodename).addEventListener("click", function( event ) {
|
2014-06-04 20:11:06 +00:00
|
|
|
var tname = this.id;
|
|
|
|
var url = "/confluent-api/nodes/" + tname + "/console/session";
|
|
|
|
new ConsoleWindow(url, tname);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}); // end document
|