diff --git a/public/app/features/panel/panel_directive.js b/public/app/features/panel/panel_directive.js index b4c1a2d6a0f..9d1b6b54b76 100644 --- a/public/app/features/panel/panel_directive.js +++ b/public/app/features/panel/panel_directive.js @@ -12,9 +12,9 @@ function (angular, $) { restrict: 'E', templateUrl: 'app/features/panel/partials/panel.html', transclude: true, + scope: { ctrl: "=" }, link: function(scope, elem) { var panelContainer = elem.find('.panel-container'); - scope.$watchGroup(['fullscreen', 'height', 'panel.height', 'row.height'], function() { panelContainer.css({ minHeight: scope.height || scope.panel.height || scope.row.height, display: 'block' }); elem.toggleClass('panel-fullscreen', scope.fullscreen ? true : false); diff --git a/public/app/features/panel/panel_loader.ts b/public/app/features/panel/panel_loader.ts index 8dc46f494a1..612cacd3b98 100644 --- a/public/app/features/panel/panel_loader.ts +++ b/public/app/features/panel/panel_loader.ts @@ -5,26 +5,42 @@ import config from 'app/core/config'; import {unknownPanelDirective} from '../../plugins/panel/unknown/module'; +var directiveModule = angular.module('grafana.directives'); + /** @ngInject */ -function panelLoader($parse, dynamicDirectiveSrv) { - return dynamicDirectiveSrv.create({ - directive: scope => { - let panelInfo = config.panels[scope.panel.type]; - if (!panelInfo) { - return Promise.resolve({ - name: 'panel-directive-' + scope.panel.type, - fn: unknownPanelDirective - }); +function panelLoader($compile, dynamicDirectiveSrv) { + return { + restrict: 'E', + link: function(scope, elem, attrs) { + + function addDirective(name, component) { + if (!component.registered) { + directiveModule.component(attrs.$normalize(name), component); + component.registered = true; + } + + var child = angular.element(document.createElement(name)); + child.attr('dashboard', 'dashboard'); + child.attr('panel', 'panel'); + $compile(child)(scope); + + elem.empty(); + elem.append(child); } - return System.import(panelInfo.module).then(function(panelModule) { - return { - name: 'panel-directive-' + scope.panel.type, - fn: panelModule.panel, - }; + var panelElemName = 'panel-directive-' + scope.panel.type; + let panelInfo = config.panels[scope.panel.type]; + if (!panelInfo) { + addDirective(panelElemName, unknownPanelDirective); + } + + System.import(panelInfo.module).then(function(panelModule) { + addDirective(panelElemName, panelModule.component); + }).catch(err => { + console.log('Panel err: ', err); }); - }, - }); + } + }; } angular.module('grafana.directives').directive('panelLoader', panelLoader); diff --git a/public/app/features/panel/panel_menu.js b/public/app/features/panel/panel_menu.js index 30b61418d72..ec0f2301675 100644 --- a/public/app/features/panel/panel_menu.js +++ b/public/app/features/panel/panel_menu.js @@ -11,16 +11,16 @@ function (angular, $, _) { .directive('panelMenu', function($compile, linkSrv) { var linkTemplate = '' + - '{{panel.title | interpolateTemplateVars:this}}' + + '{{ctrl.panel.title}}' + '' + - ' {{panelMeta.timeInfo}}' + + ' {{panelMeta.timeInfo}}' + ''; function createExternalLinkMenu($scope) { var template = '