Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #731
  • Loading branch information
gashcrumb committed Nov 6, 2013
1 parent 19b1e06 commit 9504df5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
23 changes: 23 additions & 0 deletions hawtio-web/src/main/webapp/app/core/js/helpers.ts
Expand Up @@ -293,6 +293,29 @@ if (!Object.keys) {

module Core {

export function parseMBean(mbean) {
var answer = {};

var parts = mbean.split(":");
if (parts.length === 2) {
answer['domain'] = parts[0];
answer['attributes'] = {};

var nameValues = parts[1].split(",");
nameValues.forEach((str) => {
var nameValue = str.split("=");
if (nameValue.length == 2) {
answer['attributes'][nameValue[0]] = nameValue[1];
}
});

return answer;
}

return {};
}



/*
* log out the current user, should be in helpers.ts really
Expand Down
22 changes: 17 additions & 5 deletions hawtio-web/src/main/webapp/app/karaf/js/server.ts
Expand Up @@ -35,17 +35,29 @@ module Karaf {
if (angular.isArray(response)) {
var mbean = response[0];
if (mbean) {
jolokia.getAttribute(mbean, "Instances", onSuccess(onInstances));
jolokia.getAttribute(mbean, "Instances", onSuccess((response) => {
onInstances(response, mbean);
}));
}
}
}

function onInstances(instances) {
function onInstances(instances, mbean) {
if (instances) {
// console.log("Instances is " + JSON.stringify(instances));

var parsedMBean = Core.parseMBean(mbean);
var instanceName = 'root';
if ('attributes' in parsedMBean) {
if ('name' in parsedMBean['attributes']) {
instanceName = parsedMBean['attributes']['name'];
}
}

//log.debug("mbean: ", Core.parseMBean(mbean));
//log.debug("Instances: ", instances);

// the name is the first child
var rootInstance = instances['root'];
var rootInstance = instances[instanceName];
$scope.data.name = rootInstance.Name;
$scope.data.state = rootInstance.State;
$scope.data.root = rootInstance["Is Root"];
Expand Down Expand Up @@ -92,4 +104,4 @@ module Karaf {
Core.$apply($scope);
}
}
}
}

0 comments on commit 9504df5

Please sign in to comment.