grafana/public/app/features/plugins/plugin_list_ctrl.ts

31 lines
795 B
TypeScript
Raw Normal View History

2017-12-20 05:33:33 -06:00
import angular from 'angular';
import _ from 'lodash';
export class PluginListCtrl {
plugins: any[];
tabIndex: number;
navModel: any;
2017-11-30 10:28:24 -06:00
searchQuery: string;
allPlugins: any[];
/** @ngInject */
constructor(private backendSrv: any, $location, navModelSrv) {
this.tabIndex = 0;
2017-12-20 05:33:33 -06:00
this.navModel = navModelSrv.getNav('cfg', 'plugins', 0);
2017-12-20 05:33:33 -06:00
this.backendSrv.get('api/plugins', { embedded: 0 }).then(plugins => {
this.plugins = plugins;
2017-11-30 10:28:24 -06:00
this.allPlugins = plugins;
});
}
onQueryUpdated() {
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);
});
}
}
angular.module('grafana.controllers').controller('PluginListCtrl', PluginListCtrl);