You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
require([
|
|
'underscore',
|
|
'jquery',
|
|
'splunkjs/mvc',
|
|
'splunkjs/mvc/tableview',
|
|
'splunkjs/mvc/simplexml/ready!'
|
|
], function(_, $, mvc, TableView) {
|
|
|
|
// Translations from rangemap results to CSS class
|
|
var ICONS = {
|
|
over: 'x-circle',
|
|
severe: 'alert-circle',
|
|
elevated: 'alert',
|
|
low: 'check-circle'
|
|
};
|
|
|
|
var RangeMapIconRenderer = TableView.BaseCellRenderer.extend({
|
|
canRender: function(cell) {
|
|
// Only use the cell renderer for the range field
|
|
return cell.field === 'range';
|
|
},
|
|
render: function($td, cell) {
|
|
var icon = 'question';
|
|
// Fetch the icon for the value
|
|
if (ICONS.hasOwnProperty(cell.value)) {
|
|
icon = ICONS[cell.value];
|
|
}
|
|
// Create the icon element and add it to the table cell
|
|
$td.addClass('icon').html(_.template('<i class="icon-<%-icon%> <%- range %>" title="<%- range %>"></i>', {
|
|
icon: icon,
|
|
range: cell.value
|
|
}));
|
|
}
|
|
});
|
|
|
|
mvc.Components.get('table1').getVisualization(function(tableView){
|
|
// Register custom cell renderer, the table will re-render automatically
|
|
tableView.addCellRenderer(new RangeMapIconRenderer());
|
|
});
|
|
|
|
});
|