Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first spike at #736 to browse the swagger REST APIs in the fabric
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters