mysql-connector: minor refactor
This commit is contained in:
2
dist/datasource-zabbix/datasource.js
vendored
2
dist/datasource-zabbix/datasource.js
vendored
@@ -372,7 +372,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
// Use history
|
||||
if (_this2.enableDirectDBConnection) {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo, options).then(function (history) {
|
||||
return _this2.zabbix.dbConnector.handleHistory(history, items);
|
||||
return _this2.zabbix.dbConnector.handleGrafanaTSResponse(history, items);
|
||||
});
|
||||
} else {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo).then(function (history) {
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
8
dist/datasource-zabbix/zabbixDBConnector.js
vendored
8
dist/datasource-zabbix/zabbixDBConnector.js
vendored
@@ -71,11 +71,11 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'handleHistory',
|
||||
value: function handleHistory(history, items) {
|
||||
key: 'handleGrafanaTSResponse',
|
||||
value: function handleGrafanaTSResponse(history, items) {
|
||||
var addHostName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
|
||||
return convertHistory(history, items, addHostName);
|
||||
return convertGrafanaTSResponse(history, items, addHostName);
|
||||
}
|
||||
}, {
|
||||
key: 'invokeSQLQuery',
|
||||
@@ -113,7 +113,7 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function convertHistory(time_series, items, addHostName) {
|
||||
function convertGrafanaTSResponse(time_series, items, addHostName) {
|
||||
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate
|
||||
var grafanaSeries = _.map(time_series, function (series) {
|
||||
var itemid = series.name;
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
dist/test/datasource-zabbix/datasource.js
vendored
2
dist/test/datasource-zabbix/datasource.js
vendored
@@ -232,7 +232,7 @@ var ZabbixAPIDatasource = function () {
|
||||
// Use history
|
||||
if (_this2.enableDirectDBConnection) {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo, options).then(function (history) {
|
||||
return _this2.zabbix.dbConnector.handleHistory(history, items);
|
||||
return _this2.zabbix.dbConnector.handleGrafanaTSResponse(history, items);
|
||||
});
|
||||
} else {
|
||||
getHistoryPromise = _this2.zabbix.getHistory(items, timeFrom, timeTo).then(function (history) {
|
||||
|
||||
@@ -91,11 +91,11 @@ function ZabbixDBConnectorFactory(datasourceSrv, backendSrv) {
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'handleHistory',
|
||||
value: function handleHistory(history, items) {
|
||||
key: 'handleGrafanaTSResponse',
|
||||
value: function handleGrafanaTSResponse(history, items) {
|
||||
var addHostName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
|
||||
return convertHistory(history, items, addHostName);
|
||||
return convertGrafanaTSResponse(history, items, addHostName);
|
||||
}
|
||||
}, {
|
||||
key: 'invokeSQLQuery',
|
||||
@@ -135,7 +135,7 @@ _angular2.default.module('grafana.services').factory('ZabbixDBConnector', Zabbix
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function convertHistory(time_series, items, addHostName) {
|
||||
function convertGrafanaTSResponse(time_series, items, addHostName) {
|
||||
var hosts = _lodash2.default.uniqBy(_lodash2.default.flatten(_lodash2.default.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate
|
||||
var grafanaSeries = _lodash2.default.map(time_series, function (series) {
|
||||
var itemid = series.name;
|
||||
|
||||
@@ -175,7 +175,7 @@ class ZabbixAPIDatasource {
|
||||
// Use history
|
||||
if (this.enableDirectDBConnection) {
|
||||
getHistoryPromise = this.zabbix.getHistory(items, timeFrom, timeTo, options)
|
||||
.then(history => this.zabbix.dbConnector.handleHistory(history, items));
|
||||
.then(history => this.zabbix.dbConnector.handleGrafanaTSResponse(history, items));
|
||||
} else {
|
||||
getHistoryPromise = this.zabbix.getHistory(items, timeFrom, timeTo)
|
||||
.then(history => responseHandler.handleHistory(history, items));
|
||||
|
||||
@@ -75,8 +75,8 @@ function ZabbixDBConnectorFactory(datasourceSrv, backendSrv) {
|
||||
});
|
||||
}
|
||||
|
||||
handleHistory(history, items, addHostName = true) {
|
||||
return convertHistory(history, items, addHostName);
|
||||
handleGrafanaTSResponse(history, items, addHostName = true) {
|
||||
return convertGrafanaTSResponse(history, items, addHostName);
|
||||
}
|
||||
|
||||
invokeSQLQuery(query) {
|
||||
@@ -115,7 +115,7 @@ angular
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function convertHistory(time_series, items, addHostName) {
|
||||
function convertGrafanaTSResponse(time_series, items, addHostName) {
|
||||
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate
|
||||
let grafanaSeries = _.map(time_series, series => {
|
||||
let itemid = series.name;
|
||||
|
||||
Reference in New Issue
Block a user