|
|
@@ -43,28 +43,30 @@ 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();
|
|
|
- }
|
|
|
+ module.directive('datasourceCustomSettingsView', function($compile) {
|
|
|
+ return {
|
|
|
+ restrict: 'E',
|
|
|
+ scope: {
|
|
|
+ dsMeta: "=",
|
|
|
+ current: "=",
|
|
|
+ },
|
|
|
+ link: function(scope, elem) {
|
|
|
+ scope.$watch("dsMeta.module", function() {
|
|
|
+ if (!scope.dsMeta) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- editorScope = options.scope.$new();
|
|
|
- datasourceSrv.get(newVal).then(function(ds) {
|
|
|
- self.addDirective(options, ds.meta.type, editorScope);
|
|
|
+ System.import(scope.dsMeta.module).then(function(module) {
|
|
|
+ console.log('datasourceCustomSettingsView', module);
|
|
|
+ var panelEl = angular.element(document.createElement('datasource-custom-settings-view-' + scope.dsMeta.id));
|
|
|
+ elem.append(panelEl);
|
|
|
+ $compile(panelEl)(scope);
|
|
|
+ }).catch(function(err) {
|
|
|
+ console.log('Failed to load plugin:', err);
|
|
|
+ scope.appEvent('alert-error', ['Plugin Load Error', 'Failed to load plugin ' + scope.dsMeta.id + ', ' + err]);
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
};
|
|
|
});
|
|
|
|
|
|
@@ -99,20 +101,6 @@ function (angular, $, config) {
|
|
|
};
|
|
|
});
|
|
|
|
|
|
- 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('panelResizer', function($rootScope) {
|
|
|
return {
|
|
|
restrict: 'E',
|