Browse Source

tune pluginConfig directive

woodsaj 10 years ago
parent
commit
523cf21b4a

+ 1 - 1
public/app/features/org/partials/pluginEdit.html

@@ -30,7 +30,7 @@
 				<div class="clearfix"></div>
 			</div>
 			<br>
-			<plugin-config-loader></plugin-config-loader>
+			<plugin-config-loader plugin="current"></plugin-config-loader>
 			<div class="pull-right" style="margin-top: 35px">
 				<button type="submit" class="btn btn-success" ng-click="update()">Save</button>
 				<a class="btn btn-inverse" href="plugins">Cancel</a>

+ 13 - 9
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.