mysql-connector: add config options for selecting data source

and load SQL data source during plugin init
This commit is contained in:
Alexander Zobnin
2017-07-21 17:32:46 +03:00
parent 50d6694aaf
commit 6fa4baed0c
14 changed files with 359 additions and 113 deletions

View 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';