Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added clickable urls to table row details view #444

Merged
merged 1 commit into from
Aug 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions js/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,40 @@ angular.module('kibana.filters', [])
return arr.toString();
}
};

}).filter('noXml', function() {
return function(text) {
if(!_.isString(text)) {
return text;
}
return text.
replace(/&/g, '&').
replace(/</g, '&lt;').
replace(/>/g, '&gt;').
replace(/'/g, '&#39;').
replace(/"/g, '&quot;');
};
}).filter('urlLink', function() {
var //URLs starting with http://, https://, or ftp://
r1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,
//URLs starting with "www." (without // before it, or it'd re-link the ones done above).
r2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim,
//Change email addresses to mailto:: links.
r3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim;

return function(text, target, otherProp) {
if(!_.isString(text)) {
return text;
}
_.each(text.match(r1), function(url) {
text = text.replace(r1, "<a href=\"$1\" target=\"_blank\">$1</a>");
});
_.each(text.match(r2), function(url) {
text = text.replace(r2, "$1<a href=\"http://$2\" target=\"_blank\">$2</a>");
});
_.each(text.match(r3), function(url) {
text = text.replace(r3, "<a href=\"mailto:$1\">$1</a>");
});
return text;
};
});
3 changes: 2 additions & 1 deletion panels/table/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ <h5>Fields <i class=" icon-chevron-sign-left pointer " ng-click="panel.field_lis
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>
<i class='icon-ban-circle pointer' ng-click="build_search(key,value,true)"></i>
</td>
<td style="white-space:pre-wrap">{{value}}</td>
<!-- At some point we need to create a more efficient way of applying the filter pipeline -->
<td style="white-space:pre-wrap" ng-bind-html-unsafe="value|noXml|urlLink"></td>
</tr>
</table>
</td>
Expand Down