Skip to content

Commit

Permalink
show nicer icons in the wiki for different file types like camel or d…
Browse files Browse the repository at this point in the history
…ozer
  • Loading branch information
jstrachan committed Jul 15, 2013
1 parent 0dad17b commit d69ce28
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/helpers.ts
Expand Up @@ -161,6 +161,41 @@ module Wiki {
}


export function fileIconHtml(row) {
var css = null;
var icon = null;
var name = row.getProperty("name");
var extension = fileExtension(name);
var directory = row.getProperty("directory");

// TODO could we use different icons for markdown v xml v html
var xmlNamespaces = row.xmlNamespaces || row.entity.xmlNamespaces;
if (xmlNamespaces && xmlNamespaces.length) {
if (xmlNamespaces.any((ns) => Wiki.camelNamespaces.any(ns))) {
icon = "/app/camel/img/camel.png";
} else if (xmlNamespaces.any((ns) => Wiki.dozerNamespaces.any(ns))) {
icon = "/app/dozer/img/dozer.gif";
} else {
console.log("file " + name + " has namespaces " + xmlNamespaces);
}
}

if (!icon) {
if (directory) {
css = "icon-folder-close";
} else if ("xml" === extension) {
css = "icon-cog";
} else {
css = "icon-file-alt";
}
}
if (icon) {
return "<img src='" + url(icon) + "'>";
} else {
return "<i class='" + css + "'></i>";
}
}

export function iconClass(row) {
var name = row.getProperty("name");
var extension = fileExtension(name);
Expand Down
6 changes: 5 additions & 1 deletion hawtio-web/src/main/webapp/app/wiki/js/view.ts
Expand Up @@ -18,7 +18,7 @@ module Wiki {
{
field: 'name',
displayName: 'Name',
cellTemplate: '<div class="ngCellText"><a href="{{childLink(row.entity)}}"><i class="{{row | fileIconClass}}"></i> {{row.getProperty(col.field)}}</a></div>',
cellTemplate: '<div class="ngCellText"><a href="{{childLink(row.entity)}}"><span class="file-icon" ng-bind-html-unsafe="fileIconHtml(row)"></span> {{row.getProperty(col.field)}}</a></div>',
cellFilter: ""
},
{
Expand Down Expand Up @@ -68,6 +68,10 @@ module Wiki {
return Core.createHref($location, prefix + path + postFix, ["form"]);
};

$scope.fileIconHtml = (entity) => {
return Wiki.fileIconHtml(entity);
}


$scope.format = Wiki.fileFormat($scope.pageId, fileExtensionTypeRegistry);
var options = {
Expand Down

0 comments on commit d69ce28

Please sign in to comment.