build dist

This commit is contained in:
Alexander Zobnin
2018-08-28 20:47:45 +03:00
parent e48afe864d
commit 14fba8fe5e
28 changed files with 308 additions and 172 deletions

View File

@@ -39,8 +39,10 @@ System.register(['angular', 'lodash', 'jquery', './metricFunctions'], function (
}],
execute: function () {
angular.module('grafana.directives').directive('addMetricFunction',
/** @ngInject */
angular.module('grafana.directives').directive('addMetricFunction', function ($compile) {
function ($compile) {
var inputTemplate = '<input type="text"' + ' class="gf-form-input"' + ' spellcheck="false" style="display:none"></input>';
var buttonTemplate = '<a class="gf-form-label tight-form-func dropdown-toggle query-part"' + ' tabindex="1" gf-dropdown="functionMenu" data-toggle="dropdown">' + '<i class="fa fa-plus"></i></a>';

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,9 @@
'use strict';
System.register(['lodash'], function (_export, _context) {
System.register(['lodash', './migrations'], function (_export, _context) {
"use strict";
var _, _createClass, SUPPORTED_SQL_DS, defaultConfig, ZabbixDSConfigController;
var _, migrateDSConfig, _createClass, SUPPORTED_SQL_DS, defaultConfig, ZabbixDSConfigController;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@@ -14,6 +14,8 @@ System.register(['lodash'], function (_export, _context) {
return {
setters: [function (_lodash) {
_ = _lodash.default;
}, function (_migrations) {
migrateDSConfig = _migrations.migrateDSConfig;
}],
execute: function () {
_createClass = function () {
@@ -36,18 +38,24 @@ System.register(['lodash'], function (_export, _context) {
SUPPORTED_SQL_DS = ['mysql', 'postgres'];
defaultConfig = {
dbConnection: {
enable: false
}
trends: false,
dbConnectionEnable: false,
dbConnectionDatasourceId: null,
alerting: false,
addThresholds: false,
alertingMinSeverity: 3,
disableReadOnlyUsersAck: false
};
_export('ZabbixDSConfigController', ZabbixDSConfigController = function () {
/** @ngInject */
function ZabbixDSConfigController($scope, $injector, datasourceSrv) {
_classCallCheck(this, ZabbixDSConfigController);
this.datasourceSrv = datasourceSrv;
this.current.jsonData = migrateDSConfig(this.current.jsonData);
_.defaults(this.current.jsonData, defaultConfig);
this.sqlDataSources = this.getSupportedSQLDataSources();
}
@@ -66,8 +74,6 @@ System.register(['lodash'], function (_export, _context) {
}());
_export('ZabbixDSConfigController', ZabbixDSConfigController);
ZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';
}
};
});

View File

@@ -1 +1 @@
{"version":3,"sources":["../../src/datasource-zabbix/config.controller.js"],"names":["_","SUPPORTED_SQL_DS","defaultConfig","dbConnection","enable","ZabbixDSConfigController","$scope","$injector","datasourceSrv","defaults","current","jsonData","sqlDataSources","getSupportedSQLDataSources","datasources","getAll","filter","includes","ds","type","templateUrl"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAEDC,sB,GAAmB,CAAC,OAAD,EAAU,UAAV,C;AAEnBC,mB,GAAgB;AACpBC,sBAAc;AACZC,kBAAQ;AADI;AADM,O;;0CAMTC,wB;AACX;AACA,0CAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,aAA/B,EAA8C;AAAA;;AAC5C,eAAKA,aAAL,GAAqBA,aAArB;;AAEAR,YAAES,QAAF,CAAW,KAAKC,OAAL,CAAaC,QAAxB,EAAkCT,aAAlC;AACA,eAAKU,cAAL,GAAsB,KAAKC,0BAAL,EAAtB;AACD;;;;uDAE4B;AAC3B,gBAAIC,cAAc,KAAKN,aAAL,CAAmBO,MAAnB,EAAlB;AACA,mBAAOf,EAAEgB,MAAF,CAASF,WAAT,EAAsB,cAAM;AACjC,qBAAOd,EAAEiB,QAAF,CAAWhB,gBAAX,EAA6BiB,GAAGC,IAAhC,CAAP;AACD,aAFM,CAAP;AAGD;;;;;;;;AAGHd,+BAAyBe,WAAzB,GAAuC,wCAAvC","file":"config.controller.js","sourcesContent":["import _ from 'lodash';\n\nconst SUPPORTED_SQL_DS = ['mysql', 'postgres'];\n\nconst defaultConfig = {\n dbConnection: {\n enable: false,\n }\n};\n\nexport class ZabbixDSConfigController {\n /** @ngInject */\n constructor($scope, $injector, datasourceSrv) {\n this.datasourceSrv = datasourceSrv;\n\n _.defaults(this.current.jsonData, defaultConfig);\n this.sqlDataSources = this.getSupportedSQLDataSources();\n }\n\n getSupportedSQLDataSources() {\n let datasources = this.datasourceSrv.getAll();\n return _.filter(datasources, ds => {\n return _.includes(SUPPORTED_SQL_DS, ds.type);\n });\n }\n}\n\nZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';\n"]}
{"version":3,"sources":["../../src/datasource-zabbix/config.controller.js"],"names":["_","migrateDSConfig","SUPPORTED_SQL_DS","defaultConfig","trends","dbConnectionEnable","dbConnectionDatasourceId","alerting","addThresholds","alertingMinSeverity","disableReadOnlyUsersAck","ZabbixDSConfigController","$scope","$injector","datasourceSrv","current","jsonData","defaults","sqlDataSources","getSupportedSQLDataSources","datasources","getAll","filter","includes","ds","type"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;AACEC,qB,eAAAA,e;;;;;;;;;;;;;;;;;;;;;AAEHC,sB,GAAmB,CAAC,OAAD,EAAU,UAAV,C;AAEnBC,mB,GAAgB;AACpBC,gBAAQ,KADY;AAEpBC,4BAAoB,KAFA;AAGpBC,kCAA0B,IAHN;AAIpBC,kBAAU,KAJU;AAKpBC,uBAAe,KALK;AAMpBC,6BAAqB,CAND;AAOpBC,iCAAyB;AAPL,O;;0CAUTC,wB;;AAEX;AACA,0CAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,aAA/B,EAA8C;AAAA;;AAC5C,eAAKA,aAAL,GAAqBA,aAArB;;AAEA,eAAKC,OAAL,CAAaC,QAAb,GAAwBf,gBAAgB,KAAKc,OAAL,CAAaC,QAA7B,CAAxB;AACAhB,YAAEiB,QAAF,CAAW,KAAKF,OAAL,CAAaC,QAAxB,EAAkCb,aAAlC;AACA,eAAKe,cAAL,GAAsB,KAAKC,0BAAL,EAAtB;AACD;;;;uDAE4B;AAC3B,gBAAIC,cAAc,KAAKN,aAAL,CAAmBO,MAAnB,EAAlB;AACA,mBAAOrB,EAAEsB,MAAF,CAASF,WAAT,EAAsB,cAAM;AACjC,qBAAOpB,EAAEuB,QAAF,CAAWrB,gBAAX,EAA6BsB,GAAGC,IAAhC,CAAP;AACD,aAFM,CAAP;AAGD","file":"config.controller.js","sourcesContent":["import _ from 'lodash';\nimport { migrateDSConfig } from './migrations';\n\nconst SUPPORTED_SQL_DS = ['mysql', 'postgres'];\n\nconst defaultConfig = {\n trends: false,\n dbConnectionEnable: false,\n dbConnectionDatasourceId: null,\n alerting: false,\n addThresholds: false,\n alertingMinSeverity: 3,\n disableReadOnlyUsersAck: false\n};\n\nexport class ZabbixDSConfigController {\n\n /** @ngInject */\n constructor($scope, $injector, datasourceSrv) {\n this.datasourceSrv = datasourceSrv;\n\n this.current.jsonData = migrateDSConfig(this.current.jsonData);\n _.defaults(this.current.jsonData, defaultConfig);\n this.sqlDataSources = this.getSupportedSQLDataSources();\n }\n\n getSupportedSQLDataSources() {\n let datasources = this.datasourceSrv.getAll();\n return _.filter(datasources, ds => {\n return _.includes(SUPPORTED_SQL_DS, ds.type);\n });\n }\n}\n"]}

View File

@@ -1,9 +1,9 @@
'use strict';
System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations', './metricFunctions', './constants', './dataProcessor', './responseHandler', './zabbixAlerting.service.js', './zabbix/zabbix', './zabbix/connectors/zabbix_api/zabbixAPICore'], function (_export, _context) {
System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations', './metricFunctions', './constants', './dataProcessor', './responseHandler', './zabbix/zabbix', './zabbix/connectors/zabbix_api/zabbixAPICore'], function (_export, _context) {
"use strict";
var _, dateMath, utils, migrations, metricFunctions, c, dataProcessor, responseHandler, Zabbix, ZabbixAPIError, _slicedToArray, _createClass, ZabbixAPIDatasource;
var _, dateMath, utils, migrations, metricFunctions, c, dataProcessor, responseHandler, Zabbix, ZabbixAPIError, _slicedToArray, _createClass, ZabbixDatasource;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@@ -71,6 +71,8 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
return '(' + escapedValues.join('|') + ')';
}
_export('zabbixTemplateFormat', zabbixTemplateFormat);
function zabbixItemIdsTemplateFormat(value) {
if (typeof value === 'string') {
return value;
@@ -94,17 +96,6 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
return replacedTarget;
}
// Apply function one by one:
// sequence([a(), b(), c()]) = c(b(a()));
function sequence(funcsArray) {
return function (result) {
for (var i = 0; i < funcsArray.length; i++) {
result = funcsArray[i].call(this, result);
}
return result;
};
}
function filterEnabledTargets(targets) {
return _.filter(targets, function (target) {
return !(target.hide || !target.group || !target.host || !target.item);
@@ -123,6 +114,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}
}
// Fix for backward compatibility with lodash 2.4
return {
setters: [function (_lodash) {
_ = _lodash.default;
@@ -140,7 +132,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
dataProcessor = _dataProcessor.default;
}, function (_responseHandler) {
responseHandler = _responseHandler.default;
}, function (_zabbixAlertingServiceJs) {}, function (_zabbixZabbix) {
}, function (_zabbixZabbix) {
Zabbix = _zabbixZabbix.Zabbix;
}, function (_zabbixConnectorsZabbix_apiZabbixAPICore) {
ZabbixAPIError = _zabbixConnectorsZabbix_apiZabbixAPICore.ZabbixAPIError;
@@ -202,15 +194,13 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
};
}();
_export('ZabbixAPIDatasource', ZabbixAPIDatasource = function () {
_export('ZabbixDatasource', ZabbixDatasource = function () {
/** @ngInject */
function ZabbixAPIDatasource(instanceSettings, templateSrv, alertSrv, dashboardSrv, backendSrv, datasourceSrv, zabbixAlertingSrv) {
_classCallCheck(this, ZabbixAPIDatasource);
function ZabbixDatasource(instanceSettings, templateSrv, backendSrv, datasourceSrv, zabbixAlertingSrv) {
_classCallCheck(this, ZabbixDatasource);
this.templateSrv = templateSrv;
this.alertSrv = alertSrv;
this.dashboardSrv = dashboardSrv;
this.zabbixAlertingSrv = zabbixAlertingSrv;
// Use custom format for template variables
@@ -222,7 +212,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
this.basicAuth = instanceSettings.basicAuth;
this.withCredentials = instanceSettings.withCredentials;
var jsonData = instanceSettings.jsonData || {};
var jsonData = migrations.migrateDSConfig(instanceSettings.jsonData);
// Zabbix API credentials
this.username = jsonData.username;
@@ -246,9 +236,8 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
// Direct DB Connection options
var dbConnectionOptions = jsonData.dbConnection || {};
this.enableDirectDBConnection = dbConnectionOptions.enable;
this.datasourceId = dbConnectionOptions.datasourceId;
this.enableDirectDBConnection = jsonData.dbConnectionEnable || false;
this.datasourceId = jsonData.dbConnectionDatasourceId;
var zabbixOptions = {
url: this.url,
@@ -275,7 +264,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
*/
_createClass(ZabbixAPIDatasource, [{
_createClass(ZabbixDatasource, [{
key: 'query',
value: function query(options) {
var _this = this;
@@ -296,7 +285,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Create request for each target
var promises = _.map(options.targets, function (t) {
// Don't request undefined and hidden targets
// Don't request for hidden targets
if (t.hide) {
return [];
}
@@ -311,10 +300,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Apply Time-related functions (timeShift(), etc)
var timeFunctions = bindFunctionDefs(target.functions, 'Time');
if (timeFunctions.length) {
var _sequence = sequence(timeFunctions)([timeFrom, timeTo]),
_sequence2 = _slicedToArray(_sequence, 2),
time_from = _sequence2[0],
time_to = _sequence2[1];
var _utils$sequence = utils.sequence(timeFunctions)([timeFrom, timeTo]),
_utils$sequence2 = _slicedToArray(_utils$sequence, 2),
time_from = _utils$sequence2[0],
time_to = _utils$sequence2[1];
timeFrom = time_from;
timeTo = time_to;
@@ -328,8 +317,8 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Migrate old targets
target = migrations.migrate(target);
// Don't request undefined and hidden targets
if (target.hide || !target.group || !target.host || !target.item) {
// Don't request undefined targets
if (!target.group || !target.host || !target.item) {
return [];
}
@@ -413,19 +402,19 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
// Apply transformation functions
timeseries_data = _.cloneDeep(_.map(timeseries_data, function (timeseries) {
timeseries.datapoints = sequence(transformFunctions)(timeseries.datapoints);
timeseries.datapoints = utils.sequence(transformFunctions)(timeseries.datapoints);
return timeseries;
}));
// Apply filter functions
if (filterFunctions.length) {
timeseries_data = sequence(filterFunctions)(timeseries_data);
timeseries_data = utils.sequence(filterFunctions)(timeseries_data);
}
// Apply aggregations
if (aggregationFunctions.length) {
var dp = _.map(timeseries_data, 'datapoints');
dp = sequence(aggregationFunctions)(dp);
dp = utils.sequence(aggregationFunctions)(dp);
var aggFuncNames = _.map(metricFunctions.getCategories()['Aggregate'], 'name');
var lastAgg = _.findLast(target.functions, function (func) {
@@ -439,7 +428,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}
// Apply alias functions
_.forEach(timeseries_data, sequence(aliasFunctions));
_.forEach(timeseries_data, utils.sequence(aliasFunctions));
// Apply Time-related functions (timeShift(), etc)
// Find timeShift() function and get specified trend value
@@ -551,23 +540,18 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}, {
key: 'testDatasource',
value: function testDatasource() {
var _this8 = this;
return this.zabbix.testDataSource().then(function (result) {
var zabbixVersion = result.zabbixVersion,
dbConnectorStatus = result.dbConnectorStatus;
var zabbixVersion = void 0;
return this.zabbix.getVersion().then(function (version) {
zabbixVersion = version;
return _this8.zabbix.login();
}).then(function () {
if (_this8.enableDirectDBConnection) {
return _this8.zabbix.dbConnector.testDataSource();
} else {
return Promise.resolve();
var message = 'Zabbix API version: ' + zabbixVersion;
if (dbConnectorStatus) {
message += ', DB connector type: ' + dbConnectorStatus.dsType;
}
}).then(function () {
return {
status: "success",
title: "Success",
message: "Zabbix API version: " + zabbixVersion
message: message
};
}).catch(function (error) {
if (error instanceof ZabbixAPIError) {
@@ -582,7 +566,14 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
title: "Connection failed",
message: "Connection failed: " + error.data.message
};
} else if (typeof error === 'string') {
return {
status: "error",
title: "Connection failed",
message: "Connection failed: " + error
};
} else {
console.log(error);
return {
status: "error",
title: "Connection failed",
@@ -594,14 +585,14 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}, {
key: 'metricFindQuery',
value: function metricFindQuery(query) {
var _this9 = this;
var _this8 = this;
var result = void 0;
var parts = [];
// Split query. Query structure: group.host.app.item
_.each(utils.splitTemplateQuery(query), function (part) {
part = _this9.replaceTemplateVars(part, {});
part = _this8.replaceTemplateVars(part, {});
// Replace wildcard to regex
if (part === '*') {
@@ -638,7 +629,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}, {
key: 'annotationQuery',
value: function annotationQuery(options) {
var _this10 = this;
var _this9 = this;
var timeFrom = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000);
var timeTo = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
@@ -656,7 +647,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
return getTriggers.then(function (triggers) {
// Filter triggers by description
var triggerName = _this10.replaceTemplateVars(annotation.trigger, {});
var triggerName = _this9.replaceTemplateVars(annotation.trigger, {});
if (utils.isRegex(triggerName)) {
triggers = _.filter(triggers, function (trigger) {
return utils.buildRegex(triggerName).test(trigger.description);
@@ -673,7 +664,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
});
var objectids = _.map(triggers, 'triggerid');
return _this10.zabbix.getEvents(objectids, timeFrom, timeTo, showOkEvents).then(function (events) {
return _this9.zabbix.getEvents(objectids, timeFrom, timeTo, showOkEvents).then(function (events) {
var indexedTriggers = _.keyBy(triggers, 'triggerid');
// Hide acknowledged events if option enabled
@@ -707,13 +698,13 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}, {
key: 'alertQuery',
value: function alertQuery(options) {
var _this11 = this;
var _this10 = this;
var enabled_targets = filterEnabledTargets(options.targets);
var getPanelItems = _.map(enabled_targets, function (t) {
var target = _.cloneDeep(t);
_this11.replaceTargetVariables(target, options);
return _this11.zabbix.getItemsFromTarget(target, { itemtype: 'num' });
_this10.replaceTargetVariables(target, options);
return _this10.zabbix.getItemsFromTarget(target, { itemtype: 'num' });
});
return Promise.all(getPanelItems).then(function (results) {
@@ -723,10 +714,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
if (itemids.length === 0) {
return [];
}
return _this11.zabbix.getAlerts(itemids);
return _this10.zabbix.getAlerts(itemids);
}).then(function (triggers) {
triggers = _.filter(triggers, function (trigger) {
return trigger.priority >= _this11.alertingMinSeverity;
return trigger.priority >= _this10.alertingMinSeverity;
});
if (!triggers || triggers.length === 0) {
@@ -754,12 +745,12 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}, {
key: 'replaceTargetVariables',
value: function replaceTargetVariables(target, options) {
var _this12 = this;
var _this11 = this;
var parts = ['group', 'host', 'application', 'item'];
_.forEach(parts, function (p) {
if (target[p] && target[p].filter) {
target[p].filter = _this12.replaceTemplateVars(target[p].filter, options.scopedVars);
target[p].filter = _this11.replaceTemplateVars(target[p].filter, options.scopedVars);
}
});
target.textFilter = this.replaceTemplateVars(target.textFilter, options.scopedVars);
@@ -767,9 +758,9 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
_.forEach(target.functions, function (func) {
func.params = _.map(func.params, function (param) {
if (typeof param === 'number') {
return +_this12.templateSrv.replace(param.toString(), options.scopedVars);
return +_this11.templateSrv.replace(param.toString(), options.scopedVars);
} else {
return _this12.templateSrv.replace(param, options.scopedVars);
return _this11.templateSrv.replace(param, options.scopedVars);
}
});
});
@@ -788,14 +779,11 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
}
}]);
return ZabbixAPIDatasource;
return ZabbixDatasource;
}());
_export('ZabbixAPIDatasource', ZabbixAPIDatasource);
_export('ZabbixDatasource', ZabbixDatasource);
_export('zabbixTemplateFormat', zabbixTemplateFormat);
// Fix for backward compatibility with lodash 2.4
if (!_.includes) {
_.includes = _.contains;
}

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
System.register(['angular', 'lodash', 'jquery'], function (_export, _context) {
"use strict";
var angular, _, $;
var angular, _, $, DOCS_FUNC_REF_URL;
return {
setters: [function (_angular) {
@@ -14,9 +14,13 @@ System.register(['angular', 'lodash', 'jquery'], function (_export, _context) {
$ = _jquery.default;
}],
execute: function () {
DOCS_FUNC_REF_URL = 'http://docs.grafana-zabbix.org/reference/functions/';
angular.module('grafana.directives').directive('metricFunctionEditor',
/** @ngInject */
angular.module('grafana.directives').directive('metricFunctionEditor', function ($compile, templateSrv) {
function ($compile, templateSrv) {
var funcSpanTemplate = '<a ng-click="">{{func.def.name}}</a><span>(</span>';
var paramTemplate = '<input type="text" style="display:none"' + ' class="input-mini tight-form-func-param"></input>';
@@ -225,7 +229,7 @@ System.register(['angular', 'lodash', 'jquery'], function (_export, _context) {
}
if ($target.hasClass('fa-question-circle')) {
var docSite = "http://docs.grafana-zabbix.org/reference/functions/";
var docSite = DOCS_FUNC_REF_URL;
window.open(docSite + '#' + funcDef.name.toLowerCase(), '_blank');
return;
}

File diff suppressed because one or more lines are too long

View File

@@ -3,6 +3,7 @@
System.register([], function (_export, _context) {
"use strict";
var DS_CONFIG_SCHEMA;
/**
* Query format migration.
* This module can detect query format version and make migration.
@@ -48,9 +49,36 @@ System.register([], function (_export, _context) {
} else {
return '/.*/';
}
}return {
}function migrateDSConfig(jsonData) {
if (!jsonData) {
jsonData = {};
}
var oldVersion = jsonData.schema || 1;
jsonData.schema = DS_CONFIG_SCHEMA;
if (oldVersion === DS_CONFIG_SCHEMA) {
return jsonData;
}
if (oldVersion < 2) {
var dbConnectionOptions = jsonData.dbConnection || {};
jsonData.dbConnectionEnable = dbConnectionOptions.enable || false;
jsonData.dbConnectionDatasourceId = dbConnectionOptions.datasourceId || null;
delete jsonData.dbConnection;
}
return jsonData;
}
_export("migrateDSConfig", migrateDSConfig);
return {
setters: [],
execute: function () {}
execute: function () {
_export("DS_CONFIG_SCHEMA", DS_CONFIG_SCHEMA = 2);
_export("DS_CONFIG_SCHEMA", DS_CONFIG_SCHEMA);
}
};
});
//# sourceMappingURL=migrations.js.map

View File

@@ -1 +1 @@
{"version":3,"sources":["../../src/datasource-zabbix/migrations.js"],"names":["isGrafana2target","target","mode","hostFilter","itemFilter","downsampleFunction","host","item","filter","undefined","migrateFrom2To3version","group","name","convertToRegex","application","migrate","resultFormat","str"],"mappings":";;;;;AAAA;;;;;AAKO,WAASA,gBAAT,CAA0BC,MAA1B,EAAkC;AACvC,QAAI,CAACA,OAAOC,IAAR,IAAgBD,OAAOC,IAAP,KAAgB,CAAhC,IAAqCD,OAAOC,IAAP,KAAgB,CAAzD,EAA4D;AAC1D,UAAI,CAACD,OAAOE,UAAP,IAAqBF,OAAOG,UAA5B,IAA0CH,OAAOI,kBAAjD,IACAJ,OAAOK,IAAP,IAAeL,OAAOK,IAAP,CAAYA,IAD5B,KAECL,OAAOM,IAAP,CAAYC,MAAZ,KAAuBC,SAAvB,IAAoCR,OAAOK,IAAP,CAAYE,MAAZ,KAAuBC,SAFhE,EAE4E;AAC1E,eAAO,IAAP;AACD,OAJD,MAIO;AACL,eAAO,KAAP;AACD;AACF,KARD,MAQO;AACL,aAAO,KAAP;AACD;AACF;;8BAZeT,gB;;AAcT,WAASU,sBAAT,CAAgCT,MAAhC,EAAwC;AAC7CA,WAAOU,KAAP,CAAaH,MAAb,GAAsBP,OAAOU,KAAP,CAAaC,IAAb,KAAsB,GAAtB,GAA4B,MAA5B,GAAqCX,OAAOU,KAAP,CAAaC,IAAxE;AACAX,WAAOK,IAAP,CAAYE,MAAZ,GAAqBP,OAAOK,IAAP,CAAYM,IAAZ,KAAqB,GAArB,GAA2BC,eAAeZ,OAAOE,UAAtB,CAA3B,GAA+DF,OAAOK,IAAP,CAAYM,IAAhG;AACAX,WAAOa,WAAP,CAAmBN,MAAnB,GAA4BP,OAAOa,WAAP,CAAmBF,IAAnB,KAA4B,GAA5B,GAAkC,EAAlC,GAAuCX,OAAOa,WAAP,CAAmBF,IAAtF;AACAX,WAAOM,IAAP,CAAYC,MAAZ,GAAqBP,OAAOM,IAAP,CAAYK,IAAZ,KAAqB,KAArB,GAA6BC,eAAeZ,OAAOG,UAAtB,CAA7B,GAAiEH,OAAOM,IAAP,CAAYK,IAAlG;AACA,WAAOX,MAAP;AACD;oCANeS,sB;;AAQT,WAASK,OAAT,CAAiBd,MAAjB,EAAyB;AAC9BA,WAAOe,YAAP,GAAsBf,OAAOe,YAAP,IAAuB,aAA7C;AACA,QAAIhB,iBAAiBC,MAAjB,CAAJ,EAA8B;AAC5B,aAAOS,uBAAuBT,MAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOA,MAAP;AACD;AACF;;qBAPec,O;;AAShB,WAASF,cAAT,CAAwBI,GAAxB,EAA6B;AAC3B,QAAIA,GAAJ,EAAS;AACP,aAAO,MAAMA,GAAN,GAAY,GAAnB;AACD,KAFD,MAEO;AACL,aAAO,MAAP;AACD;AACF,G","file":"migrations.js","sourcesContent":["/**\n * Query format migration.\n * This module can detect query format version and make migration.\n */\n\nexport function isGrafana2target(target) {\n if (!target.mode || target.mode === 0 || target.mode === 2) {\n if ((target.hostFilter || target.itemFilter || target.downsampleFunction ||\n (target.host && target.host.host)) &&\n (target.item.filter === undefined && target.host.filter === undefined)) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n}\n\nexport function migrateFrom2To3version(target) {\n target.group.filter = target.group.name === \"*\" ? \"/.*/\" : target.group.name;\n target.host.filter = target.host.name === \"*\" ? convertToRegex(target.hostFilter) : target.host.name;\n target.application.filter = target.application.name === \"*\" ? \"\" : target.application.name;\n target.item.filter = target.item.name === \"All\" ? convertToRegex(target.itemFilter) : target.item.name;\n return target;\n}\n\nexport function migrate(target) {\n target.resultFormat = target.resultFormat || 'time_series';\n if (isGrafana2target(target)) {\n return migrateFrom2To3version(target);\n } else {\n return target;\n }\n}\n\nfunction convertToRegex(str) {\n if (str) {\n return '/' + str + '/';\n } else {\n return '/.*/';\n }\n}\n"]}
{"version":3,"sources":["../../src/datasource-zabbix/migrations.js"],"names":["isGrafana2target","target","mode","hostFilter","itemFilter","downsampleFunction","host","item","filter","undefined","migrateFrom2To3version","group","name","convertToRegex","application","migrate","resultFormat","str","migrateDSConfig","jsonData","oldVersion","schema","DS_CONFIG_SCHEMA","dbConnectionOptions","dbConnection","dbConnectionEnable","enable","dbConnectionDatasourceId","datasourceId"],"mappings":";;;;;;AAAA;;;;;AAKO,WAASA,gBAAT,CAA0BC,MAA1B,EAAkC;AACvC,QAAI,CAACA,OAAOC,IAAR,IAAgBD,OAAOC,IAAP,KAAgB,CAAhC,IAAqCD,OAAOC,IAAP,KAAgB,CAAzD,EAA4D;AAC1D,UAAI,CAACD,OAAOE,UAAP,IAAqBF,OAAOG,UAA5B,IAA0CH,OAAOI,kBAAjD,IACAJ,OAAOK,IAAP,IAAeL,OAAOK,IAAP,CAAYA,IAD5B,KAECL,OAAOM,IAAP,CAAYC,MAAZ,KAAuBC,SAAvB,IAAoCR,OAAOK,IAAP,CAAYE,MAAZ,KAAuBC,SAFhE,EAE4E;AAC1E,eAAO,IAAP;AACD,OAJD,MAIO;AACL,eAAO,KAAP;AACD;AACF,KARD,MAQO;AACL,aAAO,KAAP;AACD;AACF;;8BAZeT,gB;;AAcT,WAASU,sBAAT,CAAgCT,MAAhC,EAAwC;AAC7CA,WAAOU,KAAP,CAAaH,MAAb,GAAsBP,OAAOU,KAAP,CAAaC,IAAb,KAAsB,GAAtB,GAA4B,MAA5B,GAAqCX,OAAOU,KAAP,CAAaC,IAAxE;AACAX,WAAOK,IAAP,CAAYE,MAAZ,GAAqBP,OAAOK,IAAP,CAAYM,IAAZ,KAAqB,GAArB,GAA2BC,eAAeZ,OAAOE,UAAtB,CAA3B,GAA+DF,OAAOK,IAAP,CAAYM,IAAhG;AACAX,WAAOa,WAAP,CAAmBN,MAAnB,GAA4BP,OAAOa,WAAP,CAAmBF,IAAnB,KAA4B,GAA5B,GAAkC,EAAlC,GAAuCX,OAAOa,WAAP,CAAmBF,IAAtF;AACAX,WAAOM,IAAP,CAAYC,MAAZ,GAAqBP,OAAOM,IAAP,CAAYK,IAAZ,KAAqB,KAArB,GAA6BC,eAAeZ,OAAOG,UAAtB,CAA7B,GAAiEH,OAAOM,IAAP,CAAYK,IAAlG;AACA,WAAOX,MAAP;AACD;oCANeS,sB;;AAQT,WAASK,OAAT,CAAiBd,MAAjB,EAAyB;AAC9BA,WAAOe,YAAP,GAAsBf,OAAOe,YAAP,IAAuB,aAA7C;AACA,QAAIhB,iBAAiBC,MAAjB,CAAJ,EAA8B;AAC5B,aAAOS,uBAAuBT,MAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOA,MAAP;AACD;AACF;;qBAPec,O;;AAShB,WAASF,cAAT,CAAwBI,GAAxB,EAA6B;AAC3B,QAAIA,GAAJ,EAAS;AACP,aAAO,MAAMA,GAAN,GAAY,GAAnB;AACD,KAFD,MAEO;AACL,aAAO,MAAP;AACD;AACF,GAGM,SAASC,eAAT,CAAyBC,QAAzB,EAAmC;AACxC,QAAI,CAACA,QAAL,EAAe;AACbA,iBAAW,EAAX;AACD;AACD,QAAMC,aAAaD,SAASE,MAAT,IAAmB,CAAtC;AACAF,aAASE,MAAT,GAAkBC,gBAAlB;;AAEA,QAAIF,eAAeE,gBAAnB,EAAqC;AACnC,aAAOH,QAAP;AACD;;AAED,QAAIC,aAAa,CAAjB,EAAoB;AAClB,UAAMG,sBAAsBJ,SAASK,YAAT,IAAyB,EAArD;AACAL,eAASM,kBAAT,GAA8BF,oBAAoBG,MAApB,IAA8B,KAA5D;AACAP,eAASQ,wBAAT,GAAoCJ,oBAAoBK,YAApB,IAAoC,IAAxE;AACA,aAAOT,SAASK,YAAhB;AACD;;AAED,WAAOL,QAAP;AACD;;6BAnBeD,e;;;;;kCADHI,gB,GAAmB,C","file":"migrations.js","sourcesContent":["/**\n * Query format migration.\n * This module can detect query format version and make migration.\n */\n\nexport function isGrafana2target(target) {\n if (!target.mode || target.mode === 0 || target.mode === 2) {\n if ((target.hostFilter || target.itemFilter || target.downsampleFunction ||\n (target.host && target.host.host)) &&\n (target.item.filter === undefined && target.host.filter === undefined)) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n}\n\nexport function migrateFrom2To3version(target) {\n target.group.filter = target.group.name === \"*\" ? \"/.*/\" : target.group.name;\n target.host.filter = target.host.name === \"*\" ? convertToRegex(target.hostFilter) : target.host.name;\n target.application.filter = target.application.name === \"*\" ? \"\" : target.application.name;\n target.item.filter = target.item.name === \"All\" ? convertToRegex(target.itemFilter) : target.item.name;\n return target;\n}\n\nexport function migrate(target) {\n target.resultFormat = target.resultFormat || 'time_series';\n if (isGrafana2target(target)) {\n return migrateFrom2To3version(target);\n } else {\n return target;\n }\n}\n\nfunction convertToRegex(str) {\n if (str) {\n return '/' + str + '/';\n } else {\n return '/.*/';\n }\n}\n\nexport const DS_CONFIG_SCHEMA = 2;\nexport function migrateDSConfig(jsonData) {\n if (!jsonData) {\n jsonData = {};\n }\n const oldVersion = jsonData.schema || 1;\n jsonData.schema = DS_CONFIG_SCHEMA;\n\n if (oldVersion === DS_CONFIG_SCHEMA) {\n return jsonData;\n }\n\n if (oldVersion < 2) {\n const dbConnectionOptions = jsonData.dbConnection || {};\n jsonData.dbConnectionEnable = dbConnectionOptions.enable || false;\n jsonData.dbConnectionDatasourceId = dbConnectionOptions.datasourceId || null;\n delete jsonData.dbConnection;\n }\n\n return jsonData;\n}\n"]}

View File

@@ -1,9 +1,9 @@
'use strict';
System.register(['app/plugins/sdk', './datasource', './query.controller', './config.controller'], function (_export, _context) {
System.register(['app/plugins/sdk', './datasource', './query.controller', './config.controller', './zabbixAlerting.service.js', './add-metric-function.directive', './metric-function-editor.directive'], function (_export, _context) {
"use strict";
var loadPluginCss, ZabbixAPIDatasource, ZabbixQueryController, ZabbixDSConfigController, ZabbixQueryOptionsController, ZabbixAnnotationsQueryController;
var loadPluginCss, ZabbixDatasource, ZabbixQueryController, ZabbixDSConfigController, ZabbixQueryOptionsController, ZabbixAnnotationsQueryController;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@@ -15,12 +15,12 @@ System.register(['app/plugins/sdk', './datasource', './query.controller', './con
setters: [function (_appPluginsSdk) {
loadPluginCss = _appPluginsSdk.loadPluginCss;
}, function (_datasource) {
ZabbixAPIDatasource = _datasource.ZabbixAPIDatasource;
ZabbixDatasource = _datasource.ZabbixDatasource;
}, function (_queryController) {
ZabbixQueryController = _queryController.ZabbixQueryController;
}, function (_configController) {
ZabbixDSConfigController = _configController.ZabbixDSConfigController;
}],
}, function (_zabbixAlertingServiceJs) {}, function (_addMetricFunctionDirective) {}, function (_metricFunctionEditorDirective) {}],
execute: function () {
loadPluginCss({
@@ -40,7 +40,10 @@ System.register(['app/plugins/sdk', './datasource', './query.controller', './con
ZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';
_export('Datasource', ZabbixAPIDatasource);
ZabbixQueryController.templateUrl = 'datasource-zabbix/partials/query.editor.html';
ZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';
_export('Datasource', ZabbixDatasource);
_export('ConfigCtrl', ZabbixDSConfigController);

View File

@@ -1 +1 @@
{"version":3,"sources":["../../src/datasource-zabbix/module.js"],"names":["loadPluginCss","ZabbixAPIDatasource","ZabbixQueryController","ZabbixDSConfigController","dark","light","ZabbixQueryOptionsController","templateUrl","ZabbixAnnotationsQueryController"],"mappings":";;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,a;;AACAC,yB,eAAAA,mB;;AACAC,2B,oBAAAA,qB;;AACAC,8B,qBAAAA,wB;;;;AAERH,oBAAc;AACZI,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;kCAKMC,4B;;;;AACNA,mCAA6BC,WAA7B,GAA2C,+CAA3C;;sCAEMC,gC;;;;AACNA,uCAAiCD,WAAjC,GAA+C,oDAA/C;;4BAGEN,mB;;4BACAE,wB;;2BACAD,qB;;kCACAI,4B;;sCACAE,gC","file":"module.js","sourcesContent":["import {loadPluginCss} from 'app/plugins/sdk';\nimport {ZabbixAPIDatasource} from './datasource';\nimport {ZabbixQueryController} from './query.controller';\nimport {ZabbixDSConfigController} from './config.controller';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nclass ZabbixQueryOptionsController {}\nZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';\n\nclass ZabbixAnnotationsQueryController {}\nZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';\n\nexport {\n ZabbixAPIDatasource as Datasource,\n ZabbixDSConfigController as ConfigCtrl,\n ZabbixQueryController as QueryCtrl,\n ZabbixQueryOptionsController as QueryOptionsCtrl,\n ZabbixAnnotationsQueryController as AnnotationsQueryCtrl\n};\n"]}
{"version":3,"sources":["../../src/datasource-zabbix/module.js"],"names":["loadPluginCss","ZabbixDatasource","ZabbixQueryController","ZabbixDSConfigController","dark","light","ZabbixQueryOptionsController","templateUrl","ZabbixAnnotationsQueryController"],"mappings":";;;;;;;;;;;;;;;AAASA,mB,kBAAAA,a;;AACAC,sB,eAAAA,gB;;AACAC,2B,oBAAAA,qB;;AACAC,8B,qBAAAA,wB;;;;AAKTH,oBAAc;AACZI,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;kCAKMC,4B;;;;AACNA,mCAA6BC,WAA7B,GAA2C,+CAA3C;;sCAEMC,gC;;;;AACNA,uCAAiCD,WAAjC,GAA+C,oDAA/C;;AAEAL,4BAAsBK,WAAtB,GAAoC,8CAApC;AACAJ,+BAAyBI,WAAzB,GAAuC,wCAAvC;;4BAGEN,gB;;4BACAE,wB;;2BACAD,qB;;kCACAI,4B;;sCACAE,gC","file":"module.js","sourcesContent":["import { loadPluginCss } from 'app/plugins/sdk';\nimport { ZabbixDatasource } from './datasource';\nimport { ZabbixQueryController } from './query.controller';\nimport { ZabbixDSConfigController } from './config.controller';\nimport './zabbixAlerting.service.js';\nimport './add-metric-function.directive';\nimport './metric-function-editor.directive';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nclass ZabbixQueryOptionsController {}\nZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';\n\nclass ZabbixAnnotationsQueryController {}\nZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';\n\nZabbixQueryController.templateUrl = 'datasource-zabbix/partials/query.editor.html';\nZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';\n\nexport {\n ZabbixDatasource as Datasource,\n ZabbixDSConfigController as ConfigCtrl,\n ZabbixQueryController as QueryCtrl,\n ZabbixQueryOptionsController as QueryOptionsCtrl,\n ZabbixAnnotationsQueryController as AnnotationsQueryCtrl\n};\n"]}

View File

@@ -1,4 +1,4 @@
<datasource-http-settings current="ctrl.current">
<datasource-http-settings current="ctrl.current" suggest-url="http://localhost/zabbix/api_jsonrpc.php">
</datasource-http-settings>
<div class="gf-form-group">
@@ -79,9 +79,9 @@
<h3 class="page-heading">Direct DB Connection</h3>
<gf-form-switch class="gf-form" label-class="width-12"
label="Enable"
checked="ctrl.current.jsonData.dbConnection.enable">
checked="ctrl.current.jsonData.dbConnectionEnable">
</gf-form-switch>
<div ng-if="ctrl.current.jsonData.dbConnection.enable">
<div ng-if="ctrl.current.jsonData.dbConnectionEnable">
<div class="gf-form max-width-20">
<span class="gf-form-label width-12">
SQL Data Source
@@ -94,7 +94,7 @@
</info-popover>
</span>
<div class="gf-form-select-wrapper max-width-16">
<select class="gf-form-input" ng-model="ctrl.current.jsonData.dbConnection.datasourceId"
<select class="gf-form-input" ng-model="ctrl.current.jsonData.dbConnectionDatasourceId"
ng-options="ds.id as ds.name for ds in ctrl.sqlDataSources">
</select>
</div>

View File

@@ -1,6 +1,6 @@
'use strict';
System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metricFunctions', './migrations', './add-metric-function.directive', './metric-function-editor.directive'], function (_export, _context) {
System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metricFunctions', './migrations'], function (_export, _context) {
"use strict";
var QueryCtrl, _, c, utils, metricFunctions, migrations, _createClass, ZabbixQueryController;
@@ -48,7 +48,7 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
metricFunctions = _metricFunctions;
}, function (_migrations) {
migrations = _migrations;
}, function (_addMetricFunctionDirective) {}, function (_metricFunctionEditorDirective) {}],
}],
execute: function () {
_createClass = function () {
function defineProperties(target, props) {
@@ -401,9 +401,6 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
}(QueryCtrl));
_export('ZabbixQueryController', ZabbixQueryController);
// Set templateUrl as static property
ZabbixQueryController.templateUrl = 'datasource-zabbix/partials/query.editor.html';
}
};
});

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +1,13 @@
"use strict";
System.register(["lodash", "q", "../module", "../datasource"], function (_export, _context) {
System.register(["lodash", "../module", "../datasource"], function (_export, _context) {
"use strict";
var _, Q, Promise, Datasource, zabbixTemplateFormat;
var _, Datasource, zabbixTemplateFormat;
return {
setters: [function (_lodash) {
_ = _lodash.default;
}, function (_q) {
Q = _q.default;
Promise = _q.Promise;
}, function (_module) {
Datasource = _module.Datasource;
}, function (_datasource) {
@@ -24,27 +21,26 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
beforeEach(function () {
ctx.instanceSettings = {
jsonData: {
alerting: true,
alerting: false,
username: 'zabbix',
password: 'zabbix',
trends: true,
trendsFrom: '14d',
trendsRange: '7d',
dbConnection: {
enabled: false
}
dbConnectionEnable: false
}
};
ctx.templateSrv = {};
ctx.alertSrv = {};
ctx.dashboardSrv = {};
ctx.backendSrv = {
datasourceRequest: jest.fn()
};
ctx.datasourceSrv = {};
ctx.zabbixAlertingSrv = {
setPanelAlertState: jest.fn(),
removeZabbixThreshold: jest.fn()
};
ctx.zabbix = function () {};
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.backendSrv, ctx.datasourceSrv, ctx.zabbixAlertingSrv);
});
describe('When querying data', function () {
@@ -52,9 +48,6 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
ctx.ds.replaceTemplateVars = function (str) {
return str;
};
ctx.ds.alertQuery = function () {
return Q.when([]);
};
});
ctx.options = {
@@ -117,10 +110,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
ctx.ds.replaceTemplateVars = function (str) {
return str;
};
ctx.ds.alertQuery = function () {
return Q.when([]);
};
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }]));
ctx.ds.zabbix.zabbixAPI.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }]));
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([{
hosts: [{ hostid: "10001", name: "Zabbix server" }],
@@ -244,10 +234,10 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
return str;
};
ctx.ds.zabbix = {
getGroups: jest.fn().mockReturnValue(Q.when([])),
getHosts: jest.fn().mockReturnValue(Q.when([])),
getApps: jest.fn().mockReturnValue(Q.when([])),
getItems: jest.fn().mockReturnValue(Q.when([]))
getGroups: jest.fn().mockReturnValue(Promise.resolve([])),
getHosts: jest.fn().mockReturnValue(Promise.resolve([])),
getApps: jest.fn().mockReturnValue(Promise.resolve([])),
getItems: jest.fn().mockReturnValue(Promise.resolve([]))
};
});
@@ -411,9 +401,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
"hosts": [{ "hostid": "10631", "name": "Test host" }],
"item": "Test item"
}];
ctx.ds.zabbix.getItemsFromTarget = function () {
return Promise.resolve(targetItems);
};
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve(targetItems));
options = {
"panelId": 10,
@@ -434,9 +422,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
"expression": "{15915}<100"
}];
ctx.ds.zabbix.getAlerts = function () {
return Promise.resolve(itemTriggers);
};
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
return ctx.ds.alertQuery(options).then(function (resp) {
expect(resp.thresholds).toHaveLength(1);
@@ -453,9 +439,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
"expression": "{15915}<=100"
}];
ctx.ds.zabbix.getAlerts = function () {
return Promise.resolve(itemTriggers);
};
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
return ctx.ds.alertQuery(options).then(function (resp) {
expect(resp.thresholds.length).toBe(1);
@@ -472,9 +456,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
"expression": "{15915}>=30"
}];
ctx.ds.zabbix.getAlerts = function () {
return Promise.resolve(itemTriggers);
};
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
return ctx.ds.alertQuery(options).then(function (resp) {
expect(resp.thresholds.length).toBe(1);
@@ -491,9 +473,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
"expression": "{15915}=50"
}];
ctx.ds.zabbix.getAlerts = function () {
return Promise.resolve(itemTriggers);
};
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
return ctx.ds.alertQuery(options).then(function (resp) {
expect(resp.thresholds.length).toBe(1);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
'use strict';
System.register(['../migrations'], function (_export, _context) {
"use strict";
var migrateDSConfig, DS_CONFIG_SCHEMA;
return {
setters: [function (_migrations) {
migrateDSConfig = _migrations.migrateDSConfig;
DS_CONFIG_SCHEMA = _migrations.DS_CONFIG_SCHEMA;
}],
execute: function () {
describe('Migrations', function () {
var ctx = {};
describe('When migrating datasource config', function () {
beforeEach(function () {
ctx.jsonData = {
dbConnection: {
enable: true,
datasourceId: 1
}
};
});
it('should change direct DB connection setting to flat style', function () {
migrateDSConfig(ctx.jsonData);
expect(ctx.jsonData).toMatchObject({
dbConnectionEnable: true,
dbConnectionDatasourceId: 1,
schema: DS_CONFIG_SCHEMA
});
});
it('should not touch anything if schema is up to date', function () {
ctx.jsonData = {
futureOptionOne: 'foo',
futureOptionTwo: 'bar',
schema: DS_CONFIG_SCHEMA
};
migrateDSConfig(ctx.jsonData);
expect(ctx.jsonData).toMatchObject({
futureOptionOne: 'foo',
futureOptionTwo: 'bar',
schema: DS_CONFIG_SCHEMA
});
expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();
expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();
});
});
});
}
};
});
//# sourceMappingURL=migrations.test.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/datasource-zabbix/specs/migrations.test.js"],"names":["migrateDSConfig","DS_CONFIG_SCHEMA","describe","ctx","beforeEach","jsonData","dbConnection","enable","datasourceId","it","expect","toMatchObject","dbConnectionEnable","dbConnectionDatasourceId","schema","futureOptionOne","futureOptionTwo","toBeUndefined"],"mappings":";;;;;;;;AAASA,qB,eAAAA,e;AAAiBC,sB,eAAAA,gB;;;;AAE1BC,eAAS,YAAT,EAAuB,YAAM;AAC3B,YAAIC,MAAM,EAAV;;AAEAD,iBAAS,kCAAT,EAA6C,YAAM;AACjDE,qBAAW,YAAM;AACfD,gBAAIE,QAAJ,GAAe;AACbC,4BAAc;AACZC,wBAAQ,IADI;AAEZC,8BAAc;AAFF;AADD,aAAf;AAMD,WAPD;;AASAC,aAAG,0DAAH,EAA+D,YAAM;AACnET,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCC,kCAAoB,IADa;AAEjCC,wCAA0B,CAFO;AAGjCC,sBAAQb;AAHyB,aAAnC;AAKD,WAPD;;AASAQ,aAAG,mDAAH,EAAwD,YAAM;AAC5DN,gBAAIE,QAAJ,GAAe;AACbU,+BAAiB,KADJ;AAEbC,+BAAiB,KAFJ;AAGbF,sBAAQb;AAHK,aAAf;AAKAD,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCI,+BAAiB,KADgB;AAEjCC,+BAAiB,KAFgB;AAGjCF,sBAAQb;AAHyB,aAAnC;AAKAS,mBAAOP,IAAIE,QAAJ,CAAaO,kBAApB,EAAwCK,aAAxC;AACAP,mBAAOP,IAAIE,QAAJ,CAAaQ,wBAApB,EAA8CI,aAA9C;AACD,WAdD;AAeD,SAlCD;AAmCD,OAtCD","file":"migrations.test.js","sourcesContent":["import { migrateDSConfig, DS_CONFIG_SCHEMA } from '../migrations';\n\ndescribe('Migrations', () => {\n let ctx = {};\n\n describe('When migrating datasource config', () => {\n beforeEach(() => {\n ctx.jsonData = {\n dbConnection: {\n enable: true,\n datasourceId: 1\n }\n };\n });\n\n it('should change direct DB connection setting to flat style', () => {\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n dbConnectionEnable: true,\n dbConnectionDatasourceId: 1,\n schema: DS_CONFIG_SCHEMA\n });\n });\n\n it('should not touch anything if schema is up to date', () => {\n ctx.jsonData = {\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n };\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n });\n expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();\n expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();\n });\n });\n});\n"]}

View File

@@ -250,10 +250,26 @@ System.register(['lodash', 'moment'], function (_export, _context) {
};
}
// Fix for backward compatibility with lodash 2.4
/**
* Apply function one by one: `sequence([a(), b(), c()]) = c(b(a()))`
* @param {*} funcsArray functions to apply
*/
_export('callOnce', callOnce);
function sequence(funcsArray) {
return function (result) {
for (var i = 0; i < funcsArray.length; i++) {
result = funcsArray[i].call(this, result);
}
return result;
};
}
// Fix for backward compatibility with lodash 2.4
_export('sequence', sequence);
return {
setters: [function (_lodash) {
_ = _lodash.default;

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
System.register(['lodash'], function (_export, _context) {
"use strict";
var _, _createClass, NOT_IMPLEMENTED, DBConnector;
var _, _createClass, DBConnector, ZabbixNotImplemented;
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@@ -34,8 +34,6 @@ System.register(['lodash'], function (_export, _context) {
};
}();
NOT_IMPLEMENTED = 'Method should be implemented in subclass of DBConnector';
DBConnector = function () {
function DBConnector(options, backendSrv, datasourceSrv) {
_classCallCheck(this, DBConnector);
@@ -44,7 +42,8 @@ System.register(['lodash'], function (_export, _context) {
this.datasourceSrv = datasourceSrv;
this.datasourceId = options.datasourceId;
this.datasourceName = options.datasourceName;
this.datasourceType = null;
this.datasourceTypeId = null;
this.datasourceTypeName = null;
}
_createClass(DBConnector, [{
@@ -55,7 +54,9 @@ System.register(['lodash'], function (_export, _context) {
var ds = _.find(this.datasourceSrv.getAll(), { 'id': this.datasourceId });
if (ds) {
return this.datasourceSrv.loadDatasource(ds.name).then(function (ds) {
_this.datasourceType = ds.meta.id;
_this.datasourceName = ds.name;
_this.datasourceTypeId = ds.meta.id;
_this.datasourceTypeName = ds.meta.name;
return ds;
});
} else {
@@ -65,17 +66,17 @@ System.register(['lodash'], function (_export, _context) {
}, {
key: 'testDataSource',
value: function testDataSource() {
throw NOT_IMPLEMENTED;
throw new ZabbixNotImplemented('testDataSource()');
}
}, {
key: 'getHistory',
value: function getHistory() {
throw NOT_IMPLEMENTED;
throw new ZabbixNotImplemented('getHistory()');
}
}, {
key: 'getTrends',
value: function getTrends() {
throw NOT_IMPLEMENTED;
throw new ZabbixNotImplemented('getTrends()');
}
}]);
@@ -83,6 +84,27 @@ System.register(['lodash'], function (_export, _context) {
}();
_export('default', DBConnector);
_export('ZabbixNotImplemented', ZabbixNotImplemented = function () {
function ZabbixNotImplemented(methodName) {
_classCallCheck(this, ZabbixNotImplemented);
this.code = null;
this.name = 'ZabbixNotImplemented';
this.message = 'Zabbix DB Connector Error: method ' + (methodName || '') + ' should be implemented in subclass of DBConnector';
}
_createClass(ZabbixNotImplemented, [{
key: 'toString',
value: function toString() {
return this.message;
}
}]);
return ZabbixNotImplemented;
}());
_export('ZabbixNotImplemented', ZabbixNotImplemented);
}
};
});

View File

@@ -1 +1 @@
{"version":3,"sources":["../../../../src/datasource-zabbix/zabbix/connectors/dbConnector.js"],"names":["_","NOT_IMPLEMENTED","DBConnector","options","backendSrv","datasourceSrv","datasourceId","datasourceName","datasourceType","ds","find","getAll","loadDatasource","name","then","meta","id","Promise","reject"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAEDC,qB,GAAkB,yD;;AAEHC,iB;AACnB,6BAAYC,OAAZ,EAAqBC,UAArB,EAAiCC,aAAjC,EAAgD;AAAA;;AAC9C,eAAKD,UAAL,GAAkBA,UAAlB;AACA,eAAKC,aAAL,GAAqBA,aAArB;AACA,eAAKC,YAAL,GAAoBH,QAAQG,YAA5B;AACA,eAAKC,cAAL,GAAsBJ,QAAQI,cAA9B;AACA,eAAKC,cAAL,GAAsB,IAAtB;AACD;;;;6CAEkB;AAAA;;AACjB,gBAAIC,KAAKT,EAAEU,IAAF,CAAO,KAAKL,aAAL,CAAmBM,MAAnB,EAAP,EAAoC,EAAC,MAAM,KAAKL,YAAZ,EAApC,CAAT;AACA,gBAAIG,EAAJ,EAAQ;AACN,qBAAO,KAAKJ,aAAL,CAAmBO,cAAnB,CAAkCH,GAAGI,IAArC,EACNC,IADM,CACD,cAAM;AACV,sBAAKN,cAAL,GAAsBC,GAAGM,IAAH,CAAQC,EAA9B;AACA,uBAAOP,EAAP;AACD,eAJM,CAAP;AAKD,aAND,MAMO;AACL,qBAAOQ,QAAQC,MAAR,8BAA0C,KAAKZ,YAA/C,gBAAP;AACD;AACF;;;2CAEgB;AACf,kBAAML,eAAN;AACD;;;uCAEY;AACX,kBAAMA,eAAN;AACD;;;sCAEW;AACV,kBAAMA,eAAN;AACD;;;;;;yBAhCkBC,W","file":"dbConnector.js","sourcesContent":["import _ from 'lodash';\n\nconst NOT_IMPLEMENTED = 'Method should be implemented in subclass of DBConnector';\n\nexport default class DBConnector {\n constructor(options, backendSrv, datasourceSrv) {\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.datasourceId = options.datasourceId;\n this.datasourceName = options.datasourceName;\n this.datasourceType = null;\n }\n\n loadDBDataSource() {\n let ds = _.find(this.datasourceSrv.getAll(), {'id': this.datasourceId});\n if (ds) {\n return this.datasourceSrv.loadDatasource(ds.name)\n .then(ds => {\n this.datasourceType = ds.meta.id;\n return ds;\n });\n } else {\n return Promise.reject(`SQL Data Source with ID ${this.datasourceId} not found`);\n }\n }\n\n testDataSource() {\n throw NOT_IMPLEMENTED;\n }\n\n getHistory() {\n throw NOT_IMPLEMENTED;\n }\n\n getTrends() {\n throw NOT_IMPLEMENTED;\n }\n}\n"]}
{"version":3,"sources":["../../../../src/datasource-zabbix/zabbix/connectors/dbConnector.js"],"names":["_","DBConnector","options","backendSrv","datasourceSrv","datasourceId","datasourceName","datasourceTypeId","datasourceTypeName","ds","find","getAll","loadDatasource","name","then","meta","id","Promise","reject","ZabbixNotImplemented","methodName","code","message"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAMcC,iB;AACnB,6BAAYC,OAAZ,EAAqBC,UAArB,EAAiCC,aAAjC,EAAgD;AAAA;;AAC9C,eAAKD,UAAL,GAAkBA,UAAlB;AACA,eAAKC,aAAL,GAAqBA,aAArB;AACA,eAAKC,YAAL,GAAoBH,QAAQG,YAA5B;AACA,eAAKC,cAAL,GAAsBJ,QAAQI,cAA9B;AACA,eAAKC,gBAAL,GAAwB,IAAxB;AACA,eAAKC,kBAAL,GAA0B,IAA1B;AACD;;;;6CAEkB;AAAA;;AACjB,gBAAIC,KAAKT,EAAEU,IAAF,CAAO,KAAKN,aAAL,CAAmBO,MAAnB,EAAP,EAAoC,EAAC,MAAM,KAAKN,YAAZ,EAApC,CAAT;AACA,gBAAII,EAAJ,EAAQ;AACN,qBAAO,KAAKL,aAAL,CAAmBQ,cAAnB,CAAkCH,GAAGI,IAArC,EACNC,IADM,CACD,cAAM;AACV,sBAAKR,cAAL,GAAsBG,GAAGI,IAAzB;AACA,sBAAKN,gBAAL,GAAwBE,GAAGM,IAAH,CAAQC,EAAhC;AACA,sBAAKR,kBAAL,GAA0BC,GAAGM,IAAH,CAAQF,IAAlC;AACA,uBAAOJ,EAAP;AACD,eANM,CAAP;AAOD,aARD,MAQO;AACL,qBAAOQ,QAAQC,MAAR,8BAA0C,KAAKb,YAA/C,gBAAP;AACD;AACF;;;2CAKgB;AACf,kBAAM,IAAIc,oBAAJ,CAAyB,kBAAzB,CAAN;AACD;;;uCAKY;AACX,kBAAM,IAAIA,oBAAJ,CAAyB,cAAzB,CAAN;AACD;;;sCAKW;AACV,kBAAM,IAAIA,oBAAJ,CAAyB,aAAzB,CAAN;AACD;;;;;;yBA5CkBlB,W;;sCAgDRkB,oB;AACX,sCAAYC,UAAZ,EAAwB;AAAA;;AACtB,eAAKC,IAAL,GAAY,IAAZ;AACA,eAAKR,IAAL,GAAY,sBAAZ;AACA,eAAKS,OAAL,2CAAoDF,cAAc,EAAlE;AACD;;;;qCAEU;AACT,mBAAO,KAAKE,OAAZ;AACD","file":"dbConnector.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * Base class for external history database connectors. Subclasses should implement `getHistory()`, `getTrends()` and\n * `testDataSource()` methods, which describe how to fetch data from source other than Zabbix API.\n */\nexport default class DBConnector {\n constructor(options, backendSrv, datasourceSrv) {\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.datasourceId = options.datasourceId;\n this.datasourceName = options.datasourceName;\n this.datasourceTypeId = null;\n this.datasourceTypeName = null;\n }\n\n loadDBDataSource() {\n let ds = _.find(this.datasourceSrv.getAll(), {'id': this.datasourceId});\n if (ds) {\n return this.datasourceSrv.loadDatasource(ds.name)\n .then(ds => {\n this.datasourceName = ds.name;\n this.datasourceTypeId = ds.meta.id;\n this.datasourceTypeName = ds.meta.name;\n return ds;\n });\n } else {\n return Promise.reject(`SQL Data Source with ID ${this.datasourceId} not found`);\n }\n }\n\n /**\n * Send test request to datasource in order to ensure it's working.\n */\n testDataSource() {\n throw new ZabbixNotImplemented('testDataSource()');\n }\n\n /**\n * Get history data from external sources.\n */\n getHistory() {\n throw new ZabbixNotImplemented('getHistory()');\n }\n\n /**\n * Get trends data from external sources.\n */\n getTrends() {\n throw new ZabbixNotImplemented('getTrends()');\n }\n}\n\n// Define Zabbix DB Connector exception type for non-implemented methods\nexport class ZabbixNotImplemented {\n constructor(methodName) {\n this.code = null;\n this.name = 'ZabbixNotImplemented';\n this.message = `Zabbix DB Connector Error: method ${methodName || ''} should be implemented in subclass of DBConnector`;\n }\n\n toString() {\n return this.message;\n }\n}\n"]}

View File

@@ -167,7 +167,7 @@ System.register(['lodash', './mysql', './postgres', '../dbConnector'], function
_createClass(SQLConnector, [{
key: 'loadSQLDialect',
value: function loadSQLDialect() {
if (this.datasourceType === supportedDatabases.postgres) {
if (this.datasourceTypeId === supportedDatabases.postgres) {
this.sqlDialect = postgres;
} else {
this.sqlDialect = mysql;

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,9 @@
'use strict';
System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbix_api/zabbixAPIConnector', './connectors/sql/sqlConnector', './proxy/cachingProxy'], function (_export, _context) {
System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbix_api/zabbixAPIConnector', './connectors/sql/sqlConnector', './proxy/cachingProxy', './connectors/dbConnector'], function (_export, _context) {
"use strict";
var _, utils, responseHandler, ZabbixAPIConnector, SQLConnector, CachingProxy, _slicedToArray, _createClass, REQUESTS_TO_PROXYFY, REQUESTS_TO_CACHE, REQUESTS_TO_BIND, Zabbix;
var _, utils, responseHandler, ZabbixAPIConnector, SQLConnector, CachingProxy, ZabbixNotImplemented, _slicedToArray, _createClass, REQUESTS_TO_PROXYFY, REQUESTS_TO_CACHE, REQUESTS_TO_BIND, Zabbix;
function _toConsumableArray(arr) {
if (Array.isArray(arr)) {
@@ -99,6 +99,8 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
SQLConnector = _connectorsSqlSqlConnector.SQLConnector;
}, function (_proxyCachingProxy) {
CachingProxy = _proxyCachingProxy.CachingProxy;
}, function (_connectorsDbConnector) {
ZabbixNotImplemented = _connectorsDbConnector.ZabbixNotImplemented;
}],
execute: function () {
_slicedToArray = function () {
@@ -282,6 +284,37 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}
}
}
}, {
key: 'testDataSource',
value: function testDataSource() {
var _this = this;
var zabbixVersion = void 0;
var dbConnectorStatus = void 0;
return this.getVersion().then(function (version) {
zabbixVersion = version;
return _this.login();
}).then(function () {
if (_this.enableDirectDBConnection) {
return _this.dbConnector.testDataSource();
} else {
return Promise.resolve();
}
}).catch(function (error) {
if (error instanceof ZabbixNotImplemented) {
return Promise.resolve();
}
return Promise.reject(error);
}).then(function (testResult) {
if (testResult) {
dbConnectorStatus = {
dsType: _this.dbConnector.datasourceTypeName,
dsName: _this.dbConnector.datasourceName
};
}
return { zabbixVersion: zabbixVersion, dbConnectorStatus: dbConnectorStatus };
});
}
}, {
key: 'getItemsFromTarget',
value: function getItemsFromTarget(target, options) {
@@ -324,11 +357,11 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}, {
key: 'getAllHosts',
value: function getAllHosts(groupFilter) {
var _this = this;
var _this2 = this;
return this.getGroups(groupFilter).then(function (groups) {
var groupids = _.map(groups, 'groupid');
return _this.zabbixAPI.getHosts(groupids);
return _this2.zabbixAPI.getHosts(groupids);
});
}
}, {
@@ -341,22 +374,22 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}, {
key: 'getAllApps',
value: function getAllApps(groupFilter, hostFilter) {
var _this2 = this;
var _this3 = this;
return this.getHosts(groupFilter, hostFilter).then(function (hosts) {
var hostids = _.map(hosts, 'hostid');
return _this2.zabbixAPI.getApps(hostids);
return _this3.zabbixAPI.getApps(hostids);
});
}
}, {
key: 'getApps',
value: function getApps(groupFilter, hostFilter, appFilter) {
var _this3 = this;
var _this4 = this;
return this.getHosts(groupFilter, hostFilter).then(function (hosts) {
var hostids = _.map(hosts, 'hostid');
if (appFilter) {
return _this3.zabbixAPI.getApps(hostids).then(function (apps) {
return _this4.zabbixAPI.getApps(hostids).then(function (apps) {
return filterByQuery(apps, appFilter);
});
} else {
@@ -370,16 +403,16 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}, {
key: 'getAllItems',
value: function getAllItems(groupFilter, hostFilter, appFilter) {
var _this4 = this;
var _this5 = this;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
return this.getApps(groupFilter, hostFilter, appFilter).then(function (apps) {
if (apps.appFilterEmpty) {
return _this4.zabbixAPI.getItems(apps.hostids, undefined, options.itemtype);
return _this5.zabbixAPI.getItems(apps.hostids, undefined, options.itemtype);
} else {
var appids = _.map(apps, 'applicationid');
return _this4.zabbixAPI.getItems(undefined, appids, options.itemtype);
return _this5.zabbixAPI.getItems(undefined, appids, options.itemtype);
}
}).then(function (items) {
if (!options.showDisabledItems) {
@@ -421,7 +454,7 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}, {
key: 'getTriggers',
value: function getTriggers(groupFilter, hostFilter, appFilter, options) {
var _this5 = this;
var _this6 = this;
var promises = [this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter), this.getApps(groupFilter, hostFilter, appFilter)];
@@ -443,13 +476,13 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
return query;
}).then(function (query) {
return _this5.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
return _this6.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
});
}
}, {
key: 'getHistoryTS',
value: function getHistoryTS(items, timeRange, options) {
var _this6 = this;
var _this7 = this;
var _timeRange = _slicedToArray(timeRange, 2),
timeFrom = _timeRange[0],
@@ -457,7 +490,7 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
if (this.enableDirectDBConnection) {
return this.getHistoryDB(items, timeFrom, timeTo, options).then(function (history) {
return _this6.dbConnector.handleGrafanaTSResponse(history, items);
return _this7.dbConnector.handleGrafanaTSResponse(history, items);
});
} else {
return this.zabbixAPI.getHistory(items, timeFrom, timeTo).then(function (history) {
@@ -468,7 +501,7 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
}, {
key: 'getTrends',
value: function getTrends(items, timeRange, options) {
var _this7 = this;
var _this8 = this;
var _timeRange2 = _slicedToArray(timeRange, 2),
timeFrom = _timeRange2[0],
@@ -476,7 +509,7 @@ System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbi
if (this.enableDirectDBConnection) {
return this.getTrendsDB(items, timeFrom, timeTo, options).then(function (history) {
return _this7.dbConnector.handleGrafanaTSResponse(history, items);
return _this8.dbConnector.handleGrafanaTSResponse(history, items);
});
} else {
var valueType = options.consolidateBy || options.valueType;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long