Skip to content

Commit

Permalink
#160: First spike of karaf server tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Apr 27, 2013
1 parent 43a1768 commit 027632d
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hawtio-web/src/main/webapp/app/karaf/html/layoutKaraf.html
@@ -1,5 +1,8 @@
<div ng-controller="Jmx.MBeansController"></div>
<ul class="nav nav-tabs" ng-controller="Core.NavBarController">
<li ng-class='{active : isActive("#/karaf/server")}'>
<a ng-href="{{link('#/karaf/server')}}">Server</a>
</li>
<li ng-class='{active : isActive("#/karaf/features")}'>
<a ng-href="#/karaf/features{{hash}}">Features</a>
</li>
Expand Down
25 changes: 25 additions & 0 deletions hawtio-web/src/main/webapp/app/karaf/html/server.html
@@ -0,0 +1,25 @@
<div class="row-fluid" ng-controller="Karaf.ServerController">

<dl class="dl-horizontal">
<dt>Name</dt>
<dd>{{data.name}}</dd>
<dt>Version</dt>
<dd>{{data.version}}</dd>
<dt>State</dt>
<dd>{{data.state}}</dd>
<dt>Is root</dt>
<dd>{{data.root}}</dd>
<dt>Location</dt>
<dd>{{data.location}}</dd>
<dt>SSH Port</dt>
<dd>{{data.sshPort}}</dd>
<dt>RMI Registry Port</dt>
<dd>{{data.rmiRegistryPort}}</dd>
<dt>RMI Server Port</dt>
<dd>{{data.rmiServerPort}}</dd>
<dt>PID</dt>
<dd>{{data.pid}}</dd>
</dl>

</div>

8 changes: 8 additions & 0 deletions hawtio-web/src/main/webapp/app/karaf/js/karafPlugin.ts
Expand Up @@ -2,6 +2,7 @@ module Karaf {
var pluginName = 'karaf';
angular.module(pluginName, ['bootstrap', 'ngResource', 'hawtioCore']).config(($routeProvider) => {
$routeProvider.
when('/karaf/server', {templateUrl: 'app/karaf/html/server.html'}).
when('/karaf/features', {templateUrl: 'app/karaf/html/features.html'}).
when('/karaf/feature/:name/:version', {templateUrl: 'app/karaf/html/feature.html'})
}).
Expand All @@ -17,6 +18,13 @@ module Karaf {
isActive: (workspace: Workspace) => workspace.isTopTabActive("karafTab")
});

workspace.subLevelTabs.push( {
content: '<i class="icon-list"></i> Server',
title: "View information about this OSGi container",
isValid: (workspace: Workspace) => workspace.isKarafFolder(),
href: () => "#/karaf/server"
});

workspace.subLevelTabs.push( {
content: '<i class="icon-list"></i> Features',
title: "View the available bundles in this OSGi container",
Expand Down
62 changes: 62 additions & 0 deletions hawtio-web/src/main/webapp/app/karaf/js/server.ts
@@ -0,0 +1,62 @@
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;
}
}
}

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

// TODO: we need the framework and version from another mbean

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 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);
}
}

}

0 comments on commit 027632d

Please sign in to comment.