submenu.ts 1.4 KB

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