submenu.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 variableSrv,
  11. private templateSrv,
  12. private $location) {
  13. this.annotations = this.dashboard.templating.list;
  14. this.variables = this.variableSrv.variables;
  15. }
  16. annotationStateChanged() {
  17. this.$rootScope.$broadcast('refresh');
  18. }
  19. getValuesForTag(variable, tagKey) {
  20. return this.variableSrv.getValuesForTag(variable, tagKey);
  21. }
  22. variableUpdated(variable) {
  23. this.variableSrv.variableUpdated(variable).then(() => {
  24. this.$rootScope.$emit('template-variable-value-updated');
  25. this.$rootScope.$broadcast('refresh');
  26. });
  27. }
  28. openEditView(editview) {
  29. var search = _.extend(this.$location.search(), {editview: editview});
  30. this.$location.search(search);
  31. }
  32. exitBuildMode() {
  33. this.dashboard.toggleEditMode();
  34. }
  35. }
  36. export function submenuDirective() {
  37. return {
  38. restrict: 'E',
  39. templateUrl: 'public/app/features/dashboard/submenu/submenu.html',
  40. controller: SubmenuCtrl,
  41. bindToController: true,
  42. controllerAs: 'ctrl',
  43. scope: {
  44. dashboard: "=",
  45. }
  46. };
  47. }
  48. angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);