Add options for table

This commit is contained in:
akotynski
2018-02-14 11:52:40 +01:00
parent 5d2bae75a0
commit cc87f731aa
10 changed files with 166 additions and 14 deletions

View File

@@ -74,9 +74,15 @@ System.register(['lodash', 'app/core/table_model', './constants'], function (_ex
return convertHistory(history, items, addHostName, convertTextCallback);
}function handleHistoryAsTable(history, items, target) {
var table = new TableModel();
table.addColumn({ text: 'Host' });
table.addColumn({ text: 'Item' });
table.addColumn({ text: 'Key' });
if (target.table.host) {
table.addColumn({ text: 'Host' });
}
if (target.table.item) {
table.addColumn({ text: 'Item' });
}
if (target.table.key) {
table.addColumn({ text: 'Key' });
}
table.addColumn({ text: 'Last value' });
var grouped_history = _.groupBy(history, 'itemid');
@@ -85,6 +91,10 @@ System.register(['lodash', 'app/core/table_model', './constants'], function (_ex
var lastPoint = _.last(itemHistory);
var lastValue = lastPoint ? lastPoint.value : null;
if (target.table.skipEmptyValues && (!lastValue || lastValue === '')) {
return;
}
// Regex-based extractor
if (target.textFilter) {
lastValue = extractText(lastValue, target.textFilter, target.useCaptureGroups);
@@ -93,7 +103,19 @@ System.register(['lodash', 'app/core/table_model', './constants'], function (_ex
var host = _.first(item.hosts);
host = host ? host.name : "";
table.rows.push([host, item.name, item.key_, lastValue]);
var row = [];
if (target.table.host) {
row.push(host);
}
if (target.table.item) {
row.push(item.name);
}
if (target.table.key) {
row.push(item.key_);
}
row.push(lastValue);
table.rows.push(row);
});
return table;