diff --git a/public/app/features/annotations/partials/editor.html b/public/app/features/annotations/partials/editor.html index 0f244998c17..875f205c1f9 100644 --- a/public/app/features/annotations/partials/editor.html +++ b/public/app/features/annotations/partials/editor.html @@ -44,7 +44,7 @@
| - + {{annotation.name}} | diff --git a/public/app/features/panel/panel_directive.js b/public/app/features/panel/panel_directive.js index 504c5843004..0c3ab11a9a7 100644 --- a/public/app/features/panel/panel_directive.js +++ b/public/app/features/panel/panel_directive.js @@ -56,8 +56,8 @@ function (angular, $, config) { return; } - System.import(scope.dsMeta.module).then(function(module) { - console.log('datasourceCustomSettingsView', module); + System.import(scope.dsMeta.module).then(function() { + elem.empty(); var panelEl = angular.element(document.createElement('datasource-custom-settings-view-' + scope.dsMeta.id)); elem.append(panelEl); $compile(panelEl)(scope); @@ -70,6 +70,45 @@ function (angular, $, config) { }; }); + module.service('dynamicDirectiveSrv', function($compile, $parse, datasourceSrv) { + var self = this; + + this.addDirective = function(options, type, editorScope) { + var panelEl = angular.element(document.createElement(options.name + '-' + type)); + options.parentElem.append(panelEl); + $compile(panelEl)(editorScope); + }; + + this.define = function(options) { + var editorScope; + options.scope.$watch(options.datasourceProperty, function(newVal) { + if (editorScope) { + editorScope.$destroy(); + options.parentElem.empty(); + } + + editorScope = options.scope.$new(); + datasourceSrv.get(newVal).then(function(ds) { + self.addDirective(options, ds.meta.id, editorScope); + }); + }); + }; + }); + + module.directive('datasourceEditorView', function(dynamicDirectiveSrv) { + return { + restrict: 'E', + link: function(scope, elem, attrs) { + dynamicDirectiveSrv.define({ + datasourceProperty: attrs.datasource, + name: attrs.name, + scope: scope, + parentElem: elem, + }); + } + }; + }); + module.directive('queryEditorLoader', function($compile, $parse, datasourceSrv) { return { restrict: 'E', |