navbar.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /** @ngInject */
  10. constructor(private $scope, private $rootScope, private contextSrv) {
  11. }
  12. showSearch() {
  13. this.$rootScope.appEvent('show-dash-search');
  14. }
  15. navItemClicked(navItem, evt) {
  16. if (navItem.clickHandler) {
  17. navItem.clickHandler();
  18. evt.preventDefault();
  19. }
  20. }
  21. }
  22. export function navbarDirective() {
  23. return {
  24. restrict: 'E',
  25. templateUrl: 'public/app/core/components/navbar/navbar.html',
  26. controller: NavbarCtrl,
  27. bindToController: true,
  28. controllerAs: 'ctrl',
  29. scope: {
  30. model: "=",
  31. },
  32. link: function(scope, elem) {
  33. }
  34. };
  35. }
  36. export function pageH1() {
  37. return {
  38. restrict: 'E',
  39. template: `
  40. <h1>
  41. <i class="{{::model.node.icon}}" ng-if="::model.node.icon"></i>
  42. <img ng-src="{{::model.node.img}}" ng-if="::model.node.img"></i>
  43. {{::model.node.text}}
  44. </h1>
  45. `,
  46. scope: {
  47. model: "=",
  48. }
  49. };
  50. }
  51. coreModule.directive('pageH1', pageH1);
  52. coreModule.directive('navbar', navbarDirective);