submenu.ts 1.3 KB

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