plugin_list_ctrl.ts 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. ///<reference path="../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. export class PluginListCtrl {
  4. plugins: any[];
  5. tabIndex: number;
  6. navModel: any;
  7. /** @ngInject */
  8. constructor(private backendSrv: any, $location, navModelSrv) {
  9. this.tabIndex = 0;
  10. this.navModel = navModelSrv.getPluginsNav();
  11. var pluginType = $location.search().type || 'panel';
  12. switch (pluginType) {
  13. case "datasource": {
  14. this.tabIndex = 1;
  15. break;
  16. }
  17. case "app": {
  18. this.tabIndex = 2;
  19. break;
  20. }
  21. case "panel":
  22. default:
  23. this.tabIndex = 0;
  24. }
  25. this.backendSrv.get('api/plugins', {embedded: 0, type: pluginType}).then(plugins => {
  26. this.plugins = plugins;
  27. });
  28. }
  29. }
  30. angular.module('grafana.controllers').controller('PluginListCtrl', PluginListCtrl);