topnav.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. define([
  2. 'angular',
  3. 'kbn'
  4. ],
  5. function (angular) {
  6. 'use strict';
  7. angular
  8. .module('grafana.directives')
  9. .directive('topnav', function($rootScope, contextSrv) {
  10. return {
  11. restrict: 'E',
  12. transclude: true,
  13. scope: {
  14. title: "@",
  15. section: "@",
  16. titleAction: "&",
  17. subnav: "=",
  18. },
  19. template:
  20. '<div class="navbar navbar-static-top"><div class="navbar-inner"><div class="container-fluid">' +
  21. '<div class="top-nav">' +
  22. '<a class="top-nav-menu-btn pointer" ng-if="!contextSrv.sidemenu" ng-click="toggle()">' +
  23. '<img class="logo-icon" src="img/fav32.png"></img> ' +
  24. '<i class="fa fa-bars"></i>' +
  25. '</a>' +
  26. '<span class="icon-circle top-nav-icon">' +
  27. '<i ng-class="icon"></i>' +
  28. '</span>' +
  29. '<span ng-show="section">' +
  30. '<span class="top-nav-title">{{section}}</span>' +
  31. '<i class="top-nav-breadcrumb-icon fa fa-angle-right"></i>' +
  32. '</span>' +
  33. '<a ng-click="titleAction()" class="top-nav-title">' +
  34. '{{title}}' +
  35. '</a>' +
  36. '<i ng-show="subnav" class="top-nav-breadcrumb-icon fa fa-angle-right"></i>' +
  37. '</div><div ng-transclude></div></div></div></div>',
  38. link: function(scope, elem, attrs) {
  39. scope.icon = attrs.icon;
  40. scope.contextSrv = contextSrv;
  41. scope.toggle = function() {
  42. $rootScope.appEvent('toggle-sidemenu');
  43. };
  44. }
  45. };
  46. });
  47. });