Replace native map() and forEach() methods by lodash.
This commit is contained in:
@@ -265,14 +265,14 @@ function findNearestLeft(series, point) {
|
||||
|
||||
function timeShift(interval, range) {
|
||||
let shift = utils.parseTimeShiftInterval(interval) / 1000;
|
||||
return range.map(time => {
|
||||
return _.map(range, time => {
|
||||
return time - shift;
|
||||
});
|
||||
}
|
||||
|
||||
function unShiftTimeSeries(interval, datapoints) {
|
||||
let unshift = utils.parseTimeShiftInterval(interval);
|
||||
return datapoints.map(dp => {
|
||||
return _.map(datapoints, dp => {
|
||||
return [
|
||||
dp[0],
|
||||
dp[1] + unshift
|
||||
|
||||
@@ -137,6 +137,10 @@ class ZabbixAPIDatasource {
|
||||
return getHistoryPromise.then(timeseries_data => {
|
||||
return this.applyDataProcessingFunctions(timeseries_data, target);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -393,7 +397,7 @@ class ZabbixAPIDatasource {
|
||||
// Replace template variables
|
||||
replaceTargetVariables(target, options) {
|
||||
let parts = ['group', 'host', 'application', 'item'];
|
||||
parts.forEach(p => {
|
||||
_.forEach(parts, p => {
|
||||
if (target[p] && target[p].filter) {
|
||||
target[p].filter = this.replaceTemplateVars(target[p].filter, options.scopedVars);
|
||||
}
|
||||
@@ -401,7 +405,7 @@ class ZabbixAPIDatasource {
|
||||
target.textFilter = this.replaceTemplateVars(target.textFilter, options.scopedVars);
|
||||
|
||||
_.forEach(target.functions, func => {
|
||||
func.params = func.params.map(param => {
|
||||
func.params = _.map(func.params, param => {
|
||||
if (typeof param === 'number') {
|
||||
return +this.templateSrv.replace(param.toString(), options.scopedVars);
|
||||
} else {
|
||||
|
||||
@@ -189,7 +189,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
.then(expandItems);
|
||||
|
||||
function expandItems(items) {
|
||||
items.forEach(item => {
|
||||
_.forEach(items, item => {
|
||||
item.item = item.name;
|
||||
item.name = utils.expandItemName(item.item, item.key_);
|
||||
return item;
|
||||
|
||||
@@ -64,6 +64,9 @@ class ZabbixAPICoreService {
|
||||
|
||||
// Success
|
||||
return response.data.result;
|
||||
})
|
||||
.catch(() => {
|
||||
return Promise.reject(new ZabbixAPIError({data: "Connection Error"}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user