Skip to content

Commit

Permalink
added icon to the profile view for #45
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Apr 10, 2013
1 parent 6561ba0 commit 4b94763
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
19 changes: 16 additions & 3 deletions hawtio-web/src/main/webapp/app/camel/js/helpers.ts
Expand Up @@ -102,9 +102,22 @@ module Camel {
}
}

export function getRouteNodeIcon(nodeSettings) {
var imageName = nodeSettings["icon"] || "generic24.png";
return url("/app/camel/img/" + imageName);
export function getRouteNodeIcon(nodeSettingsOrXmlNode) {
var nodeSettings = null;
if (nodeSettingsOrXmlNode) {
var nodeName = nodeSettingsOrXmlNode.localName;
if (nodeName) {
nodeSettings = getCamelSchema(nodeName);
} else {
nodeSettings = nodeSettingsOrXmlNode;
}
}
if (nodeSettings) {
var imageName = nodeSettings["icon"] || "generic24.png";
return url("/app/camel/img/" + imageName);
} else {
return null;
}
}

export function getSelectedRouteNode(workspace:Workspace) {
Expand Down
29 changes: 29 additions & 0 deletions hawtio-web/src/main/webapp/app/camel/js/profile.ts
Expand Up @@ -5,11 +5,13 @@ module Camel {
$scope.data = [];
$scope.search = "";
$scope.calcManually = true;
$scope.icons = {};

var columnDefs: any[] = [
{
field: 'id',
displayName: 'Id',
cellTemplate: '<div class="ngCellText"><span ng-bind-html-unsafe="rowIcon(row.entity.id)"/> {{row.entity.id}}</div>',
cellFilter: null,
width: "*",
resizable: true
Expand Down Expand Up @@ -72,6 +74,33 @@ module Camel {
}
];

$scope.rowIcon = (id) => {
var answer = $scope.icons[id];
if (!answer) {
var routeXml = Core.pathGet(workspace.selection, ["routeXmlNode"]);
if (routeXml) {
var routeId = routeXml.getAttribute("id");
var node = (id === routeId) ? routeXml : null;
if (!node) {
// now lets find the child node which has the given id
var child = $(routeXml).find('*[id="' + id + '"]');
if (child && child.length) {
node = child[0];
}
}
if (node) {
var icon = Camel.getRouteNodeIcon(node);
if (icon) {
answer = "<img src='" + icon + "'>";
$scope.icons[id] = answer;
}
}
}

}
return answer;
};

$scope.gridOptions = {
data: 'data',
displayFooter: true,
Expand Down

0 comments on commit 4b94763

Please sign in to comment.