build dist
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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"]}
|
||||
@@ -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
67
dist/datasource-zabbix/zabbix/zabbix.js
vendored
67
dist/datasource-zabbix/zabbix/zabbix.js
vendored
@@ -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;
|
||||
|
||||
2
dist/datasource-zabbix/zabbix/zabbix.js.map
vendored
2
dist/datasource-zabbix/zabbix/zabbix.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user