submenu.ts 1.2 KB

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