Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
first baby steps towards a file/wiki based camel viewer/editor re #228
…we can at least show a little tree of the routes in the XML file so far
  • Loading branch information
jstrachan committed Apr 5, 2013
1 parent 7c590ec commit da23879
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hawtio-web/src/main/webapp/app/camel/js/helpers.ts
Expand Up @@ -104,6 +104,37 @@ module Camel {
return _apacheCamelModel.languages[nodeName];
}

export function loadCamelTree(xml: string) {
var doc = $.parseXML(xml);

// TODO get id from camelContext
var id = "camelContext";
var folder = new Folder(id);
folder.addClass = "org-apache-camel-context";
folder.domain = Camel.jmxDomain;
folder.typeName = "context";

var context = $(doc).find("camelContext");
if (!context || !context.length) {
context = $(doc).find("routes");
}

if (context && context.length) {
$(context).children("route").each((idx, route) => {
// TODO add a route node!!
var id = route.getAttribute("id") || "route" + idx;
var routeFolder = new Folder(id);
routeFolder.addClass = "org-apache-camel-route";
routeFolder.typeName = "routes";
routeFolder.domain = Camel.jmxDomain;
folder.children.push(routeFolder);

addRouteChildren(routeFolder, route);
});
}
return folder;
}

/**
* Adds the route children to the given folder for each step in the route
*/
Expand Down
21 changes: 21 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/html/camel.html
@@ -0,0 +1,21 @@
<div ng-controller="Wiki.CamelController">
<div class="row-fluid">
<div id="tree-container" class="span3">
<ul id="tree-ctrl" class="nav">
<li>
<a data-toggle="collapse" data-target="#camelxml">
<span>Camel Tree</span>
</a>
</li>
</ul>
<div id="camelxml" class="in collapse"></div>
</div>

<div class="span9">
<!--
<ng-include src="'app/jmx/html/subLevelTabs.html'"></ng-include>
<div id="properties" ng-view></div>
-->
</div>
</div>
</div>
Empty file.
23 changes: 23 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/html/layoutCamelTree.html
@@ -0,0 +1,23 @@
<div class="row-fluid">
<div id="tree-container" class="span3">
<ul id="tree-ctrl" class="nav">
<li>
<a data-toggle="collapse" data-target="#cameltree">
<span>Camel Tree</span>
</a>
</li>
</ul>
<div id="cameltree" class="in collapse" ng-controller="Camel.TreeController"></div>
</div>

<div class="span9">
<ng-include src="'app/jmx/html/subLevelTabs.html'"></ng-include>
<div id="properties" ng-view></div>
</div>
<div id="alert-area" class="span9"></div>
<!--
<div class="span8 scrollable">
<div id="properties" class="scrollable" ng-view></div>
</div>
-->
</div>
39 changes: 39 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/camel.ts
@@ -0,0 +1,39 @@
module Wiki {

export function CamelController($scope, $location, $routeParams, workspace:Workspace, wikiRepository:GitWikiRepository) {
$scope.pageId = Wiki.pageId($routeParams, $location);

$scope.$watch('workspace.tree', function () {
if (!$scope.git && Git.getGitMBean(workspace)) {
// lets do this asynchronously to avoid Error: $digest already in progress
//console.log("Reloading the view as we now seem to have a git mbean!");
setTimeout(updateView, 50);
}
});

$scope.$on("$routeChangeSuccess", function (event, current, previous) {
// lets do this asynchronously to avoid Error: $digest already in progress
setTimeout(updateView, 50);
});

updateView();

function onResults(response) {
var text = response.text;
if (text) {
var tree = Camel.loadCamelTree(text);
if (tree) {
tree.key = $scope.pageId + "_camelContext";

var treeElement = $("#camelxml");
Jmx.enableTree($scope, $location, workspace, treeElement, [tree]);
}
}
Core.$apply($scope);
}

function updateView() {
$scope.git = wikiRepository.getPage($scope.pageId, $scope.objectId, onResults);
}
}
}
13 changes: 13 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/view.ts
@@ -1,5 +1,10 @@
module Wiki {

var camelNamespaces = ["http://camel.apache.org/schema/spring", "http://camel.apache.org/schema/blueprint"];
var springNamespaces = ["http://www.springframework.org/schema/beans"]
var droolsNamespaces = ["http://drools.org/schema/drools-spring"]


export function ViewController($scope, $location, $routeParams, workspace:Workspace, marked, fileExtensionTypeRegistry, wikiRepository:GitWikiRepository, $compile) {

$scope.pageId = Wiki.pageId($routeParams, $location);
Expand Down Expand Up @@ -44,6 +49,14 @@ module Wiki {
}
}
} else {
var xmlNamespaces = child.xmlNamespaces;
if (xmlNamespaces && xmlNamespaces.length) {
if (xmlNamespaces.any((ns) => camelNamespaces.any(ns))) {
prefix = "#/wiki/camel";
} else {
console.log("child " + path + " has namespaces " + xmlNamespaces);
}
}
if (child.path.endsWith(".form")) {
postFix = "?form=/";
}
Expand Down
2 changes: 2 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/wikiPlugin.ts
Expand Up @@ -5,6 +5,7 @@ module Wiki {
$routeProvider.
when('/wiki/view/:page', {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/formTable/:page', {templateUrl: 'app/wiki/html/formTable.html'}).
when('/wiki/camel/:page', {templateUrl: 'app/wiki/html/camel.html'}).
when('/wiki/version/:page/:objectId', {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/diff/:page/:objectId/:baseObjectId', {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/create/:page', {templateUrl: 'app/wiki/html/createPage.html'}).
Expand All @@ -21,6 +22,7 @@ module Wiki {
$routeProvider.
when('/wiki/view/' + path, {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/formTable/' + path, {templateUrl: 'app/wiki/html/formTable.html'}).
when('/wiki/camel/' + path, {templateUrl: 'app/wiki/html/camel.html'}).
when('/wiki/version' + path + '/:objectId', {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/diff' + path + '/:objectId/:baseObjectId', {templateUrl: 'app/wiki/html/viewPage.html'}).
when('/wiki/create/' + path, {templateUrl: 'app/wiki/html/createPage.html'}).
Expand Down

0 comments on commit da23879

Please sign in to comment.