submenu.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 $location) {
  13. this.annotations = this.dashboard.templating.list;
  14. this.variables = this.dashboard.templating.list;
  15. }
  16. disableAnnotation(annotation) {
  17. annotation.enable = !annotation.enable;
  18. this.$rootScope.$broadcast('refresh');
  19. }
  20. getValuesForTag(variable, tagKey) {
  21. return this.templateValuesSrv.getValuesForTag(variable, tagKey);
  22. }
  23. variableUpdated(variable) {
  24. this.templateValuesSrv.variableUpdated(variable).then(() => {
  25. this.$rootScope.$emit('template-variable-value-updated');
  26. this.$rootScope.$broadcast('refresh');
  27. });
  28. }
  29. }
  30. export function submenuDirective() {
  31. return {
  32. restrict: 'E',
  33. templateUrl: 'public/app/features/dashboard/submenu/submenu.html',
  34. controller: SubmenuCtrl,
  35. bindToController: true,
  36. controllerAs: 'ctrl',
  37. scope: {
  38. dashboard: "=",
  39. }
  40. };
  41. }
  42. angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);