refactor of PR #526
This commit is contained in:
@@ -17,12 +17,6 @@
|
|||||||
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
|
||||||
<gf-form-switch class="gf-form" label="Skip empty values" checked="ctrl.target.table.skipEmptyValues" on-change="ctrl.onTargetBlur()">
|
|
||||||
</gf-form-switch>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form gf-form--grow">
|
<div class="gf-form gf-form--grow">
|
||||||
<div class="gf-form-label gf-form-label--grow"></div>
|
<div class="gf-form-label gf-form-label--grow"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -169,12 +163,19 @@
|
|||||||
<!-- Query options -->
|
<!-- Query options -->
|
||||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||||
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||||
<gf-form-switch class="gf-form"
|
<gf-form-switch class="gf-form" label-class="width-10"
|
||||||
label="Show disabled items"
|
label="Show disabled items"
|
||||||
checked="ctrl.target.options.showDisabledItems"
|
checked="ctrl.target.options.showDisabledItems"
|
||||||
on-change="ctrl.onQueryOptionChange()">
|
on-change="ctrl.onQueryOptionChange()">
|
||||||
</gf-form-switch>
|
</gf-form-switch>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||||
|
<gf-form-switch class="gf-form" label-class="width-10"
|
||||||
|
label="Skip empty values"
|
||||||
|
checked="ctrl.target.options.skipEmptyValues"
|
||||||
|
on-change="ctrl.onQueryOptionChange()">
|
||||||
|
</gf-form-switch>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Item IDs editor mode -->
|
<!-- Item IDs editor mode -->
|
||||||
|
|||||||
6
dist/datasource-zabbix/query.controller.js
vendored
6
dist/datasource-zabbix/query.controller.js
vendored
@@ -146,7 +146,8 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
|||||||
'acknowledged': 2
|
'acknowledged': 2
|
||||||
},
|
},
|
||||||
'options': {
|
'options': {
|
||||||
'showDisabledItems': false
|
'showDisabledItems': false,
|
||||||
|
'skipEmptyValues': false
|
||||||
},
|
},
|
||||||
'table': {
|
'table': {
|
||||||
'skipEmptyValues': false
|
'skipEmptyValues': false
|
||||||
@@ -370,7 +371,8 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
|||||||
key: 'renderQueryOptionsText',
|
key: 'renderQueryOptionsText',
|
||||||
value: function renderQueryOptionsText() {
|
value: function renderQueryOptionsText() {
|
||||||
var optionsMap = {
|
var optionsMap = {
|
||||||
showDisabledItems: "Show disabled items"
|
showDisabledItems: "Show disabled items",
|
||||||
|
skipEmptyValues: "Skip empty values"
|
||||||
};
|
};
|
||||||
var options = [];
|
var options = [];
|
||||||
_.forOwn(this.target.options, function (value, key) {
|
_.forOwn(this.target.options, function (value, key) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
dist/datasource-zabbix/responseHandler.js
vendored
2
dist/datasource-zabbix/responseHandler.js
vendored
@@ -85,7 +85,7 @@ System.register(['lodash', 'app/core/table_model', './constants'], function (_ex
|
|||||||
var lastPoint = _.last(itemHistory);
|
var lastPoint = _.last(itemHistory);
|
||||||
var lastValue = lastPoint ? lastPoint.value : null;
|
var lastValue = lastPoint ? lastPoint.value : null;
|
||||||
|
|
||||||
if (target.table.skipEmptyValues && (!lastValue || lastValue === '')) {
|
if (target.options.skipEmptyValues && (!lastValue || lastValue === '')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
15
dist/datasource-zabbix/specs/datasource.spec.js
vendored
15
dist/datasource-zabbix/specs/datasource.spec.js
vendored
@@ -127,7 +127,7 @@ describe('ZabbixDatasource', () => {
|
|||||||
useCaptureGroups: true,
|
useCaptureGroups: true,
|
||||||
mode: 2,
|
mode: 2,
|
||||||
resultFormat: "table",
|
resultFormat: "table",
|
||||||
table: {
|
options: {
|
||||||
skipEmptyValues: false
|
skipEmptyValues: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,18 @@ describe('ZabbixDatasource', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should skip item when last value is empty', () => {
|
it('should skip item when last value is empty', () => {
|
||||||
ctx.options.targets[0].skipEmptyValues = true;
|
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||||
|
{
|
||||||
|
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||||
|
itemid: "10100", name: "System information", key_: "system.uname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hosts: [{hostid: "10002", name: "Server02"}],
|
||||||
|
itemid: "90109", name: "System information", key_: "system.uname"
|
||||||
|
}
|
||||||
|
]));
|
||||||
|
|
||||||
|
ctx.options.targets[0].options.skipEmptyValues = true;
|
||||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||||
|
|||||||
@@ -17,12 +17,6 @@
|
|||||||
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
|
||||||
<gf-form-switch class="gf-form" label="Skip empty values" checked="ctrl.target.table.skipEmptyValues" on-change="ctrl.onTargetBlur()">
|
|
||||||
</gf-form-switch>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form gf-form--grow">
|
<div class="gf-form gf-form--grow">
|
||||||
<div class="gf-form-label gf-form-label--grow"></div>
|
<div class="gf-form-label gf-form-label--grow"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -169,12 +163,19 @@
|
|||||||
<!-- Query options -->
|
<!-- Query options -->
|
||||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||||
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||||
<gf-form-switch class="gf-form"
|
<gf-form-switch class="gf-form" label-class="width-10"
|
||||||
label="Show disabled items"
|
label="Show disabled items"
|
||||||
checked="ctrl.target.options.showDisabledItems"
|
checked="ctrl.target.options.showDisabledItems"
|
||||||
on-change="ctrl.onQueryOptionChange()">
|
on-change="ctrl.onQueryOptionChange()">
|
||||||
</gf-form-switch>
|
</gf-form-switch>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||||
|
<gf-form-switch class="gf-form" label-class="width-10"
|
||||||
|
label="Skip empty values"
|
||||||
|
checked="ctrl.target.options.skipEmptyValues"
|
||||||
|
on-change="ctrl.onQueryOptionChange()">
|
||||||
|
</gf-form-switch>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Item IDs editor mode -->
|
<!-- Item IDs editor mode -->
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
'acknowledged': 2
|
'acknowledged': 2
|
||||||
},
|
},
|
||||||
'options': {
|
'options': {
|
||||||
'showDisabledItems': false
|
'showDisabledItems': false,
|
||||||
|
'skipEmptyValues': false
|
||||||
},
|
},
|
||||||
'table': {
|
'table': {
|
||||||
'skipEmptyValues': false
|
'skipEmptyValues': false
|
||||||
@@ -301,7 +302,8 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
|
|
||||||
renderQueryOptionsText() {
|
renderQueryOptionsText() {
|
||||||
var optionsMap = {
|
var optionsMap = {
|
||||||
showDisabledItems: "Show disabled items"
|
showDisabledItems: "Show disabled items",
|
||||||
|
skipEmptyValues: "Skip empty values"
|
||||||
};
|
};
|
||||||
var options = [];
|
var options = [];
|
||||||
_.forOwn(this.target.options, (value, key) => {
|
_.forOwn(this.target.options, (value, key) => {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ function handleHistoryAsTable(history, items, target) {
|
|||||||
let lastPoint = _.last(itemHistory);
|
let lastPoint = _.last(itemHistory);
|
||||||
let lastValue = lastPoint ? lastPoint.value : null;
|
let lastValue = lastPoint ? lastPoint.value : null;
|
||||||
|
|
||||||
if(target.table.skipEmptyValues && (!lastValue || lastValue === '')) {
|
if(target.options.skipEmptyValues && (!lastValue || lastValue === '')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ describe('ZabbixDatasource', () => {
|
|||||||
useCaptureGroups: true,
|
useCaptureGroups: true,
|
||||||
mode: 2,
|
mode: 2,
|
||||||
resultFormat: "table",
|
resultFormat: "table",
|
||||||
table: {
|
options: {
|
||||||
skipEmptyValues: false
|
skipEmptyValues: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,18 @@ describe('ZabbixDatasource', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should skip item when last value is empty', () => {
|
it('should skip item when last value is empty', () => {
|
||||||
ctx.options.targets[0].skipEmptyValues = true;
|
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||||
|
{
|
||||||
|
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||||
|
itemid: "10100", name: "System information", key_: "system.uname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hosts: [{hostid: "10002", name: "Server02"}],
|
||||||
|
itemid: "90109", name: "System information", key_: "system.uname"
|
||||||
|
}
|
||||||
|
]));
|
||||||
|
|
||||||
|
ctx.options.targets[0].options.skipEmptyValues = true;
|
||||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||||
|
|||||||
Reference in New Issue
Block a user