Skip to content

Commit

Permalink
first spike at #736 to browse the swagger REST APIs in the fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Nov 8, 2013
1 parent e4301cf commit bacc4aa
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/html/apis.html
@@ -0,0 +1,23 @@
<div class="row-fluid" ng-controller="Fabric.FabricApisController">

<div class="span12 page-padded">
<div class="section-header">

<div class="section-filter">
<input type="text" class="search-query" placeholder="Filter..." ng-model="searchFilter">
<i class="icon-remove clickable" title="Clear Filter" ng-click="searchFilter = ''"></i>
</div>

</div>
</div>

<div class="">
<ul class="" ng-class="isInDashboardClass()">
<li class="" ng-repeat="api in apis | filter:searchText">
<a href="{{api.href}}">{{api.path}}</a>
</li>
</ul>
</div>
</div>


3 changes: 3 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/html/layoutFabric.html
Expand Up @@ -14,6 +14,9 @@
<li ng-show="hasMQManager" ng-class='{active : isActive("#/fabric/mq")}'>
<a ng-href="#/fabric/mq/brokers{{hash}}" title="View the Fabric based MQ brokers">MQ</a>
</li>
<li ng-show="hasFabric" ng-class='{active : isActive("#/fabric/api")}'>
<a ng-href="#/fabric/api{{hash}}" title="View the APIs in the Fabric">APIs</a>
</li>
<li ng-show="hasFabric" ng-class='{active : isActive("#/fabric/clusters")}' ng-disabled="!Fabric.getZooKeeperFacadeMBean(workspace)">
<a ng-href="{{clusterLink()}}" title="View the web application, messaging and integration clusters in this fabric">Clusters</a>
</li>
Expand Down
65 changes: 65 additions & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/apis.ts
@@ -0,0 +1,65 @@
module Fabric {

export function FabricApisController($scope, localStorage, $routeParams, $location, jolokia, workspace, $compile, $templateCache) {

$scope.path = "apis";

Fabric.initScope($scope, $location, jolokia, workspace);

function matchesFilter(text) {
var filter = $scope.searchFilter;
return !filter || (text && text.has(filter));
}

if (Fabric.fabricCreated(workspace)) {
Core.register(jolokia, $scope, {
type: 'exec',
mbean: Fabric.managerMBean,
operation: "clusterJson",
arguments: [$scope.path]},
onSuccess(onClusterData));
}


function createFlatList(array, json, path = "") {
angular.forEach(json, (value, key) => {
var childPath = path + "/" + key;

// lets check if we are a services object or a folder
var services = value["services"];
if (services && angular.isArray(services) && value["id"]) {
value["path"] = childPath;
if (services.length) {
value["href"] = "/hawtio-swagger/index.html?baseUri=" + services[0];
}
array.push(value);
} else {
createFlatList(array, value, childPath);
}
});
}

function onClusterData(response) {
if (response && response.value) {

var responseJson = response.value;
if ($scope.responseJson === responseJson) {
return;
}

$scope.responseJson = responseJson;

try {
//console.log("got JSON: " + responseJson);
var json = JSON.parse(responseJson);
$scope.apis = [];
createFlatList($scope.apis, json);
Core.$apply($scope);
} catch (e) {
console.log("Failed to parse JSON " + e);
console.log("JSON: " + responseJson);
}
}
}
}
}
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -24,6 +24,7 @@ module Fabric {
when('/fabric/mq/brokers', { templateUrl: templatePath + 'brokers.html' }).
when('/fabric/mq/brokerNetwork', { templateUrl: templatePath + 'brokerNetwork.html' }).
when('/fabric/mq/createBroker', { templateUrl: templatePath + 'createBroker.html' }).
when('/fabric/api', { templateUrl: templatePath + 'apis.html' }).
when('/fabric/test', { templateUrl: templatePath + 'test.html' });
}).

Expand Down

0 comments on commit bacc4aa

Please sign in to comment.