Skip to content

Commit

Permalink
#123 first cut of nicer endpoint categories, labels and icons - we ca…
Browse files Browse the repository at this point in the history
…n tidy over time
  • Loading branch information
jstrachan committed Jun 5, 2013
1 parent e45eb11 commit 36595ea
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 16 deletions.
101 changes: 101 additions & 0 deletions hawtio-web/src/main/webapp/app/camel/js/endpointChooser.ts
@@ -1,5 +1,106 @@
module Camel {

/**
* Define the default categories for endpoints and map them to endpoint names
*/
export var endpointCategories = {
bigdata: {
label: "Big Data",
endpoints: ["hdfs", "hbase", "lucene", "solr"],
endpointIcon: "/app/camel/img/endpointRepository24.png"
},
database: {
label: "Database",
endpoints: ["couchdb", "elasticsearch", "hbase", "jdbc", "jpa", "hibernate", "mongodb", "mybatis", "sql"],
endpointIcon: "/app/camel/img/endpointRepository24.png"
},
cloud: {
label: "Cloud",
endpoints: [
"aws-cw", "aws-ddb", "aws-sdb", "aws-ses", "aws-sns", "aws-sqs", "aws-s3",
"gauth", "ghhtp", "glogin", "gtask",
"jclouds"]
},
core: {
label: "Core",
endpoints: ["bean", "direct", "seda"]
},
messaging: {
label: "Messaging",
endpoints: ["jms", "activemq", "amqp", "cometd", "mqtt"],
endpointIcon: "/app/camel/img/endpointQueue24.png"
},
mobile: {
label: "Mobile",
endpoints: ["apns"]
},
social: {
label: "Social",
endpoints: ["atom", "irc", "rss", "smpp", "twitter", "weather"]
},
storage: {
label: "Storage",
endpointIcon: "/app/camel/img/endpointFolder24.png",
endpoints: ["file", "ftp", "sftp", "scp", "jsch"]
},
template: {
label: "Templating",
endpoints: ["freemarker", "velocity", "xquery", "xslt", "scalate", "string-template"]
}
};

/**
* Maps endpoint names to a category object
*/
export var endpointToCategory = {};

export var endpointIcon = "/app/camel/img/endpoint24.png";
/**
* specify custom label & icon properties for endpoint names
*/
export var endpointConfigurations = {
drools: {
icon: "/app/camel/img/endpointQueue24.png"
},
quartz: {
icon: "/app/camel/img/endpointTimer24.png"
},
timer: {
icon: "/app/camel/img/endpointTimer24.png"
}
};

angular.forEach(endpointCategories, (category, catKey) => {
category.id = catKey;
angular.forEach(category.endpoints, (endpoint) => {
endpointToCategory[endpoint] = category;
});
});


export function getEndpointConfig(endpointName, category) {
var answer = endpointConfigurations[endpointName];
if (!answer) {
answer = {
};
endpointConfigurations[endpointName] = answer;
}
if (!answer.label) {
answer.label = endpointName;
}
if (!answer.icon) {
answer.icon = category.endpointIcon || endpointIcon;
}
if (!answer.category) {
answer.category = category;
}
return answer;
}

export function getEndpointCategory(endpointName:string) {
return endpointToCategory[endpointName] || endpointCategories.core;
}

export function initEndpointChooserScope($scope, workspace:Workspace, jolokia) {
$scope.selectedComponentName = null;
$scope.endpointParameters = {};
Expand Down
29 changes: 13 additions & 16 deletions hawtio-web/src/main/webapp/app/wiki/js/camel.ts
Expand Up @@ -72,31 +72,28 @@ module Wiki {
var componentNames = $scope.componentNames;
if (componentNames && componentNames.length) {
$scope.componentTree = new Folder("Endpoints");
angular.forEach($scope.componentNames, (value) => {
// TODO use a mapping of endpoint names to group...
var groupName = "Core";
var groupKey = groupName;
angular.forEach($scope.componentNames, (endpointName) => {
var category = Camel.getEndpointCategory(endpointName);
var groupName = category.label || "Core";
var groupKey = category.id || groupName;
var group = $scope.componentTree.getOrElse(groupName);
var key = value;
value["_id"] = key;
var title = value["title"] || key;
var node = new Folder(title);

var value = Camel.getEndpointConfig(endpointName, category);
var key = endpointName;
var label = value["label"] || endpointName;
var node = new Folder(label);
node.key = groupKey + "_" + key;
node["nodeModel"] = value;
var tooltip = "";
var label = "";
/*
var imageUrl = Camel.getRouteNodeIcon(value);
node.icon = imageUrl;
*/
node.tooltip = tooltip;
var tooltip = value["tooltip"] || value["description"] || label;
var imageUrl = url(value["icon"] || Camel.endpointIcon);
node.icon = imageUrl;
node.tooltip = tooltip;

group.children.push(node);
});
}
});
$scope.componentActivations = ["Core_bean"];
$scope.componentActivations = ["core_bean"];

$scope.$watch('addDialog.show', function () {
if ($scope.addDialog.show) {
Expand Down

0 comments on commit 36595ea

Please sign in to comment.