submenu.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. import _ from 'lodash';
  4. export class SubmenuCtrl {
  5. annotations: any;
  6. variables: any;
  7. dashboard: any;
  8. /** @ngInject */
  9. constructor(private $rootScope,
  10. private templateValuesSrv,
  11. private templateSrv,
  12. private dynamicDashboardSrv,
  13. private $location) {
  14. this.annotations = this.dashboard.templating.list;
  15. this.variables = this.dashboard.templating.list;
  16. }
  17. disableAnnotation(annotation) {
  18. annotation.enable = !annotation.enable;
  19. this.$rootScope.$broadcast('refresh');
  20. }
  21. getValuesForTag(variable, tagKey) {
  22. return this.templateValuesSrv.getValuesForTag(variable, tagKey);
  23. }
  24. variableUpdated(variable) {
  25. this.templateValuesSrv.variableUpdated(variable).then(() => {
  26. this.dynamicDashboardSrv.update(this.dashboard);
  27. this.$rootScope.$emit('template-variable-value-updated');
  28. this.$rootScope.$broadcast('refresh');
  29. });
  30. }
  31. }
  32. export function submenuDirective() {
  33. return {
  34. restrict: 'E',
  35. templateUrl: 'public/app/features/dashboard/submenu/submenu.html',
  36. controller: SubmenuCtrl,
  37. bindToController: true,
  38. controllerAs: 'ctrl',
  39. scope: {
  40. dashboard: "=",
  41. }
  42. };
  43. }
  44. angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);