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.

24 lines
1.1 KiB

/*
* The PMThresholdIndexCellRenderer is a custom cell renderer for the threshold index field displayed in a TableView
*/
define(["/static/app/DA-ITSI-CP-vmware-dashboards/swc-vmware-cp/index.js", '/static/app/DA-ITSI-CP-vmware-dashboards/libs/backbone.js','/static/app/DA-ITSI-CP-vmware-dashboards/libs/underscore.js'],
function (SWCVMware, Backbone, _) {
const TableView = SWCVMware.TableView;
var threshold_severity_classes = ["critical", "warning", "normal", "unknown"];
var ThresholdIndexCellRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
// Various names for the threshold index field
return cell.field === 'threshold_index' || cell.field === 'status' || cell.field === 's';
},
// This render function only works when canRender returns 'true'
render: function($td, cell) {
var threshold_class = threshold_severity_classes[cell.value] || "unknown";
$td.addClass("pm-threshold-indicator-cell");
$td.html('<div class="pm-threshold-indicator-circle pm-threshold-' + threshold_class + '"/><div>');
}
});
return ThresholdIndexCellRenderer;
});