remove options to hide columns
This commit is contained in:
@@ -19,11 +19,6 @@
|
||||
</div>
|
||||
<div class="gf-form" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||
<label class="gf-form-label query-keyword width-8">Options</label>
|
||||
<gf-form-switch class="gf-form" label="Host" checked="ctrl.target.table.host" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label="Item" checked="ctrl.target.table.item" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label="Key" checked="ctrl.target.table.key" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label="Skip empty values" checked="ctrl.target.table.skipEmptyValues" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
|
||||
@@ -99,9 +99,6 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
'showDisabledItems': false
|
||||
},
|
||||
'table': {
|
||||
'host': true,
|
||||
'item': true,
|
||||
'key': true,
|
||||
'skipEmptyValues': false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,15 +56,9 @@ function handleText(history, items, target, addHostName = true) {
|
||||
|
||||
function handleHistoryAsTable(history, items, target) {
|
||||
let table = new TableModel();
|
||||
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: 'Host'});
|
||||
table.addColumn({text: 'Item'});
|
||||
table.addColumn({text: 'Key'});
|
||||
table.addColumn({text: 'Last value'});
|
||||
|
||||
let grouped_history = _.groupBy(history, 'itemid');
|
||||
@@ -85,19 +79,9 @@ function handleHistoryAsTable(history, items, target) {
|
||||
let host = _.first(item.hosts);
|
||||
host = host ? host.name : "";
|
||||
|
||||
let 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);
|
||||
table.rows.push([
|
||||
host, item.name, item.key_, lastValue
|
||||
]);
|
||||
});
|
||||
|
||||
return table;
|
||||
|
||||
@@ -128,9 +128,6 @@ describe('ZabbixDatasource', () => {
|
||||
mode: 2,
|
||||
resultFormat: "table",
|
||||
table: {
|
||||
host: true,
|
||||
item: true,
|
||||
key: true,
|
||||
skipEmptyValues: false
|
||||
}
|
||||
}
|
||||
@@ -162,22 +159,6 @@ describe('ZabbixDatasource', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return table only with `Last value` column when other columns are not selected', () => {
|
||||
ctx.options.targets[0].table = {
|
||||
host: false,
|
||||
item: false,
|
||||
key: false,
|
||||
skipEmptyValues: false
|
||||
};
|
||||
return ctx.ds.query(ctx.options).then(result => {
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.columns.length).toBe(1);
|
||||
expect(tableData.columns[0].text).toEqual('Last value');
|
||||
expect(tableData.rows[0].length).toBe(1);
|
||||
expect(tableData.rows[0][0]).toEqual('Linux last');
|
||||
});
|
||||
});
|
||||
|
||||
it('should skip item when last value is empty', () => {
|
||||
ctx.options.targets[0].skipEmptyValues = true;
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||
|
||||
Reference in New Issue
Block a user