submenu.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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, private dynamicDashboardSrv) {
  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.dynamicDashboardSrv.update(this.dashboard);
  22. this.$rootScope.$emit('template-variable-value-updated');
  23. this.$rootScope.$broadcast('refresh');
  24. });
  25. }
  26. }
  27. export function submenuDirective() {
  28. return {
  29. restrict: 'E',
  30. templateUrl: 'app/features/dashboard/submenu/submenu.html',
  31. controller: SubmenuCtrl,
  32. bindToController: true,
  33. controllerAs: 'ctrl',
  34. scope: {
  35. dashboard: "=",
  36. }
  37. };
  38. }
  39. angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);