mysql-connector: add config options for selecting data source
and load SQL data source during plugin init
This commit is contained in:
28
src/datasource-zabbix/config.controller.js
Normal file
28
src/datasource-zabbix/config.controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
const SUPPORTED_SQL_DS = ['mysql'];
|
||||
|
||||
const defaultConfig = {
|
||||
dbConnection: {
|
||||
enable: false,
|
||||
}
|
||||
};
|
||||
|
||||
export class ZabbixDSConfigController {
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, datasourceSrv) {
|
||||
this.datasourceSrv = datasourceSrv;
|
||||
|
||||
_.defaults(this.current.jsonData, defaultConfig);
|
||||
this.sqlDataSources = this.getSupportedSQLDataSources();
|
||||
}
|
||||
|
||||
getSupportedSQLDataSources() {
|
||||
let datasources = this.datasourceSrv.getAll();
|
||||
return _.filter(datasources, ds => {
|
||||
return _.includes(SUPPORTED_SQL_DS, ds.type);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';
|
||||
Reference in New Issue
Block a user