From 523cf21b4af5024c9c982a9c9404a6267291b121 Mon Sep 17 00:00:00 2001 From: woodsaj Date: Sat, 5 Dec 2015 00:34:48 +0800 Subject: [PATCH] tune pluginConfig directive --- .../app/features/org/partials/pluginEdit.html | 2 +- public/app/features/org/plugin_directive.js | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/public/app/features/org/partials/pluginEdit.html b/public/app/features/org/partials/pluginEdit.html index d77eb5ebd6c..9276fce277c 100644 --- a/public/app/features/org/partials/pluginEdit.html +++ b/public/app/features/org/partials/pluginEdit.html @@ -30,7 +30,7 @@

- +
Cancel diff --git a/public/app/features/org/plugin_directive.js b/public/app/features/org/plugin_directive.js index 8862f5580e7..6fd30730264 100644 --- a/public/app/features/org/plugin_directive.js +++ b/public/app/features/org/plugin_directive.js @@ -11,13 +11,18 @@ function (angular) { restrict: 'E', link: function(scope, elem) { var directive = 'grafana-plugin-core'; - if (scope.current.module) { - directive = 'grafana-plugin-'+scope.current.type; - } - scope.require([scope.current.module], function () { - var panelEl = angular.element(document.createElement(directive)); - elem.append(panelEl); - $compile(panelEl)(scope); + //wait for the parent scope to be applied. + scope.$watch("current", function(newVal) { + if (newVal) { + if (newVal.module) { + directive = 'grafana-plugin-'+newVal.type; + } + scope.require([newVal.module], function () { + var panelEl = angular.element(document.createElement(directive)); + elem.append(panelEl); + $compile(panelEl)(scope); + }); + } }); } }; @@ -28,8 +33,7 @@ function (angular) { restrict: 'E', templateUrl: 'app/features/org/partials/pluginConfigCore.html', transclude: true, - link: function(scope, elem) { - console.log("grafana plugin core", scope, elem); + link: function(scope) { scope.update = function() { //Perform custom save events to the plugins own backend if needed.