SubMenuCtrl.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import angular, { ILocationService } from 'angular';
  2. import _ from 'lodash';
  3. import { VariableSrv } from 'app/features/templating/all';
  4. export class SubMenuCtrl {
  5. annotations: any;
  6. variables: any;
  7. dashboard: any;
  8. /** @ngInject */
  9. constructor(private variableSrv: VariableSrv, private $location: ILocationService) {
  10. this.annotations = this.dashboard.templating.list;
  11. this.variables = this.variableSrv.variables;
  12. }
  13. annotationStateChanged() {
  14. this.dashboard.startRefresh();
  15. }
  16. variableUpdated(variable: any) {
  17. this.variableSrv.variableUpdated(variable, true);
  18. }
  19. openEditView(editview: any) {
  20. const search = _.extend(this.$location.search(), { editview: editview });
  21. this.$location.search(search);
  22. }
  23. }
  24. export function submenuDirective() {
  25. return {
  26. restrict: 'E',
  27. templateUrl: 'public/app/features/dashboard/components/SubMenu/template.html',
  28. controller: SubMenuCtrl,
  29. bindToController: true,
  30. controllerAs: 'ctrl',
  31. scope: {
  32. dashboard: '=',
  33. },
  34. };
  35. }
  36. angular.module('grafana.directives').directive('dashboardSubmenu', submenuDirective);