module.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import _ from 'lodash';
  3. import config from 'app/core/config';
  4. import {PanelDirective, PanelCtrl} from '../../../features/panel/panel';
  5. // Set and populate defaults
  6. var panelDefaults = {
  7. mode: 'starred',
  8. query: '',
  9. limit: 10,
  10. tags: []
  11. };
  12. class DashListCtrl extends PanelCtrl {
  13. dashList: any[];
  14. modes: any[];
  15. /** @ngInject */
  16. constructor($scope, $injector, private backendSrv) {
  17. super($scope, $injector);
  18. _.defaults(this.panel, panelDefaults);
  19. if (this.panel.tag) {
  20. this.panel.tags = [$scope.panel.tag];
  21. delete this.panel.tag;
  22. }
  23. }
  24. initEditMode() {
  25. this.modes = ['starred', 'search'];
  26. this.icon = "fa fa-star";
  27. this.addEditorTab('Options', () => {
  28. return {templateUrl: 'app/plugins/panel/dashlist/editor.html'};
  29. });
  30. }
  31. refresh() {
  32. var params: any = {limit: this.panel.limit};
  33. if (this.panel.mode === 'starred') {
  34. params.starred = "true";
  35. } else {
  36. params.query = this.panel.query;
  37. params.tag = this.panel.tags;
  38. }
  39. return this.backendSrv.search(params).then(result => {
  40. this.dashList = result;
  41. this.renderingCompleted();
  42. });
  43. }
  44. }
  45. class DashListPanel extends PanelDirective {
  46. controller = DashListCtrl;
  47. templateUrl = 'public/app/plugins/panel/dashlist/module.html';
  48. }
  49. export {
  50. DashListCtrl,
  51. DashListPanel as Panel
  52. }