2017-12-20 05:33:33 -06:00
|
|
|
import angular from 'angular';
|
|
|
|
import _ from 'lodash';
|
2016-02-25 07:55:31 -06:00
|
|
|
|
|
|
|
export class PluginListCtrl {
|
|
|
|
plugins: any[];
|
2016-03-14 03:10:32 -05:00
|
|
|
tabIndex: number;
|
2017-06-02 07:00:42 -05:00
|
|
|
navModel: any;
|
2017-11-30 10:28:24 -06:00
|
|
|
searchQuery: string;
|
|
|
|
allPlugins: any[];
|
2016-02-25 07:55:31 -06:00
|
|
|
|
|
|
|
/** @ngInject */
|
2017-06-02 07:00:42 -05:00
|
|
|
constructor(private backendSrv: any, $location, navModelSrv) {
|
2016-03-14 03:10:32 -05:00
|
|
|
this.tabIndex = 0;
|
2017-12-20 05:33:33 -06:00
|
|
|
this.navModel = navModelSrv.getNav('cfg', 'plugins', 0);
|
2016-03-14 03:10:32 -05:00
|
|
|
|
2017-12-20 05:33:33 -06:00
|
|
|
this.backendSrv.get('api/plugins', { embedded: 0 }).then(plugins => {
|
2016-02-25 07:55:31 -06:00
|
|
|
this.plugins = plugins;
|
2017-11-30 10:28:24 -06:00
|
|
|
this.allPlugins = plugins;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onQueryUpdated() {
|
2018-08-26 10:14:40 -05:00
|
|
|
const regex = new RegExp(this.searchQuery, 'ig');
|
2017-11-30 10:28:24 -06:00
|
|
|
this.plugins = _.filter(this.allPlugins, item => {
|
|
|
|
return regex.test(item.name) || regex.test(item.type);
|
2016-02-25 07:55:31 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-21 01:39:31 -06:00
|
|
|
angular.module('grafana.controllers').controller('PluginListCtrl', PluginListCtrl);
|