tune pluginConfig directive

This commit is contained in:
woodsaj
2015-12-05 00:34:48 +08:00
parent 3c13901695
commit 523cf21b4a
2 changed files with 14 additions and 10 deletions
@@ -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
View File
@@ -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.