navbar.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import _ from 'lodash';
  4. import $ from 'jquery';
  5. import coreModule from '../../core_module';
  6. import {NavModel, NavModelItem} from '../../nav_model_srv';
  7. export class NavbarCtrl {
  8. model: NavModel;
  9. section: NavModelItem;
  10. hasMenu: boolean;
  11. /** @ngInject */
  12. constructor(private $scope, private $rootScope, private contextSrv) {
  13. this.section = this.model.section;
  14. this.hasMenu = this.model.menu.length > 0;
  15. }
  16. showSearch() {
  17. this.$rootScope.appEvent('show-dash-search');
  18. }
  19. navItemClicked(navItem, evt) {
  20. if (navItem.clickHandler) {
  21. navItem.clickHandler();
  22. evt.preventDefault();
  23. }
  24. }
  25. }
  26. export function navbarDirective() {
  27. return {
  28. restrict: 'E',
  29. templateUrl: 'public/app/core/components/navbar/navbar.html',
  30. controller: NavbarCtrl,
  31. bindToController: true,
  32. transclude: true,
  33. controllerAs: 'ctrl',
  34. scope: {
  35. model: "=",
  36. },
  37. link: function(scope, elem) {
  38. elem.addClass('navbar');
  39. }
  40. };
  41. }
  42. coreModule.directive('navbar', navbarDirective);