module.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import _ from 'lodash';
  3. import config from 'app/core/config';
  4. import {PanelCtrl} from 'app/plugins/sdk';
  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. static templateUrl = 'module.html';
  14. dashList: any[];
  15. modes: any[];
  16. /** @ngInject */
  17. constructor($scope, $injector, private backendSrv) {
  18. super($scope, $injector);
  19. _.defaults(this.panel, panelDefaults);
  20. if (this.panel.tag) {
  21. this.panel.tags = [$scope.panel.tag];
  22. delete this.panel.tag;
  23. }
  24. }
  25. initEditMode() {
  26. super.initEditMode();
  27. this.modes = ['starred', 'search'];
  28. this.icon = "fa fa-star";
  29. this.addEditorTab('Options', () => {
  30. return {templateUrl: 'public/app/plugins/panel/dashlist/editor.html'};
  31. });
  32. }
  33. refresh() {
  34. var params: any = {limit: this.panel.limit};
  35. if (this.panel.mode === 'starred') {
  36. params.starred = "true";
  37. } else {
  38. params.query = this.panel.query;
  39. params.tag = this.panel.tags;
  40. }
  41. return this.backendSrv.search(params).then(result => {
  42. this.dashList = result;
  43. this.renderingCompleted();
  44. });
  45. }
  46. }
  47. export {DashListCtrl, DashListCtrl as PanelCtrl}