plugin_list_ctrl.ts 766 B

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