plugin_list_ctrl.ts 795 B

123456789101112131415161718192021222324252627282930
  1. import angular from 'angular';
  2. import _ from 'lodash';
  3. export class PluginListCtrl {
  4. plugins: any[];
  5. tabIndex: number;
  6. navModel: any;
  7. searchQuery: string;
  8. allPlugins: any[];
  9. /** @ngInject */
  10. constructor(private backendSrv: any, $location, navModelSrv) {
  11. this.tabIndex = 0;
  12. this.navModel = navModelSrv.getNav('cfg', 'plugins', 0);
  13. this.backendSrv.get('api/plugins', { embedded: 0 }).then(plugins => {
  14. this.plugins = plugins;
  15. this.allPlugins = plugins;
  16. });
  17. }
  18. onQueryUpdated() {
  19. const regex = new RegExp(this.searchQuery, 'ig');
  20. this.plugins = _.filter(this.allPlugins, item => {
  21. return regex.test(item.name) || regex.test(item.type);
  22. });
  23. }
  24. }
  25. angular.module('grafana.controllers').controller('PluginListCtrl', PluginListCtrl);