Skip to content

Commit

Permalink
added more data to the karaf server page & made it more async
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed May 3, 2013
1 parent f6d89c3 commit 003b944
Showing 1 changed file with 57 additions and 51 deletions.
108 changes: 57 additions & 51 deletions hawtio-web/src/main/webapp/app/karaf/js/server.ts
@@ -1,62 +1,68 @@
module Karaf {

export function ServerController($scope, $location, workspace:Workspace, jolokia) {

$scope.data = {
name: "",
version: "",
state: "",
root: "",
location: "",
sshPort: "",
rmiRegistryPort: "",
rmiServerPort: "",
pid: ""};

function render(response) {
console.log("Response is " + response);

// grab the first mbean as there should ideally only be one karaf in the JVM
if (angular.isArray(response)) {
var mbean = response[0];
if (mbean) {
var instances = jolokia.getAttribute(mbean, "Instances", onSuccess(null));
if (instances) {
console.log("Instances is " + instances);
// the name is the first child
$scope.data.name = "TODO";
// TODO: we need to get version from another mbean
$scope.data.version = "TODO";
$scope.data.state = instances['root'].State;
$scope.data.root = "TODO";
$scope.data.location = instances['root'].Location;
$scope.data.sshPort = "TODO";
$scope.data.rmiRegistryPort = "TODO";
$scope.data.rmiServerPort = "TODO";
$scope.data.pid = instances['root'].Pid;
}
}
}
export function ServerController($scope, $location, workspace:Workspace, jolokia) {

// ensure web page is updated
Core.$apply($scope);
}
$scope.data = {
name: "",
version: "",
state: "",
root: "",
location: "",
sshPort: "",
rmiRegistryPort: "",
rmiServerPort: "",
pid: ""};

// TODO: we need the framework and version from another mbean
$scope.$on('jmxTreeUpdated', reloadFunction);
$scope.$watch('workspace.tree', reloadFunction);

function loadData() {
console.log("Loading Karaf data...");
jolokia.search("org.apache.karaf:type=admin,*", onSuccess(render));
}
// TODO: we need the framework and version from another mbean

function reloadFunction() {
// if the JMX tree is reloaded its probably because a new MBean has been added or removed
// so lets reload, asynchronously just in case
setTimeout(loadData, 50);
}

function loadData() {
console.log("Loading Karaf data...");
jolokia.search("org.apache.karaf:type=admin,*", onSuccess(render));
}

$scope.$on('jmxTreeUpdated', reloadFunction);
$scope.$watch('workspace.tree', reloadFunction);
function render(response) {
console.log("Response is " + response);

function reloadFunction() {
// if the JMX tree is reloaded its probably because a new MBean has been added or removed
// so lets reload, asynchronously just in case
setTimeout(loadData, 50);
// grab the first mbean as there should ideally only be one karaf in the JVM
if (angular.isArray(response)) {
var mbean = response[0];
if (mbean) {
jolokia.getAttribute(mbean, "Instances", onSuccess(onInstances));
}
}

// ensure web page is updated
Core.$apply($scope);
}

function onInstances(instances) {
if (instances) {
console.log("Instances is " + JSON.stringify(instances));
// the name is the first child
var rootInstance = instances['root'];
$scope.data.name = rootInstance.Name;
$scope.data.state = rootInstance.State;
$scope.data.root = rootInstance["Is Root"];
$scope.data.location = rootInstance.Location;
$scope.data.sshPort = rootInstance["SSH Port"];
$scope.data.rmiRegistryPort = rootInstance["RMI Registry Port"];
$scope.data.rmiServerPort = rootInstance["RMI Server Port"];
$scope.data.pid = rootInstance.Pid;

// TODO: we need to get version from another mbean
$scope.data.version = "";

Core.$apply($scope);
}
}
}
}

0 comments on commit 003b944

Please sign in to comment.