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. constructor(private $rootScope, private templateValuesSrv, private dynamicDashboardSrv) {
  8. this.annotations = this.dashboard.templating.list;
  9. this.variables = this.dashboard.templating.list;
  10. }
  11. disableAnnotation(annotation) {
  12. annotation.enable = !annotation.enable;
  13. this.$rootScope.$broadcast('refresh');
  14. }
  15. getValuesForTag(variable, tagKey) {
  16. return this.templateValuesSrv.getValuesForTag(variable, tagKey);
  17. }
  18. variableUpdated(variable) {
  19. this.templateValuesSrv.variableUpdated(variable).then(() => {
  20. this.dynamicDashboardSrv.update(this.dashboard);
  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: '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);