diff --git a/public/app/core/directives/plugin_component.ts b/public/app/core/directives/plugin_component.ts
index d4722c6d2f5..e628fbede39 100644
--- a/public/app/core/directives/plugin_component.ts
+++ b/public/app/core/directives/plugin_component.ts
@@ -5,7 +5,7 @@ import _ from 'lodash';
import coreModule from '../core_module';
-function pluginDirectiveLoader($compile, datasourceSrv) {
+function pluginDirectiveLoader($compile, datasourceSrv, $rootScope) {
function getPluginComponentDirective(options) {
return function() {
@@ -27,30 +27,53 @@ function pluginDirectiveLoader($compile, datasourceSrv) {
function getModule(scope, attrs) {
switch (attrs.type) {
- case "metrics-query-editor":
+ // QueryCtrl
+ case "query-ctrl": {
let datasource = scope.target.datasource || scope.ctrl.panel.datasource;
return datasourceSrv.get(datasource).then(ds => {
scope.datasource = ds;
return System.import(ds.meta.module).then(dsModule => {
return {
- name: 'metrics-query-editor-' + ds.meta.id,
+ name: 'query-ctrl-' + ds.meta.id,
bindings: {target: "=", panelCtrl: "=", datasource: "="},
attrs: {"target": "target", "panel-ctrl": "ctrl", datasource: "datasource"},
Component: dsModule.QueryCtrl
};
});
});
+ }
+ // QueryOptionsCtrl
+ case "query-options-ctrl": {
+ return datasourceSrv.get(scope.ctrl.panel.datasource).then(ds => {
+ return System.import(ds.meta.module).then((dsModule): any => {
+ if (!dsModule.QueryOptionsCtrl) {
+ return {notFound: true};
+ }
- case 'datasource-config-view':
+ return {
+ name: 'query-options-ctrl-' + ds.meta.id,
+ bindings: {panelCtrl: "="},
+ attrs: {"panel-ctrl": "ctrl"},
+ Component: dsModule.QueryOptionsCtrl
+ };
+ });
+ });
+ }
+ // ConfigCtrl
+ case 'datasource-config-ctrl': {
return System.import(scope.datasourceMeta.module).then(function(dsModule) {
return {
name: 'ds-config-' + scope.datasourceMeta.id,
bindings: {meta: "=", current: "="},
attrs: {meta: "datasourceMeta", current: "current"},
- Component: dsModule.ConfigView,
+ Component: dsModule.ConfigCtrl,
};
});
+ }
+ default: {
+ $rootScope.appEvent('alert-error', ['Plugin component error', 'could not find component '+ attrs.type]);
+ }
}
}
@@ -67,6 +90,11 @@ function pluginDirectiveLoader($compile, datasourceSrv) {
}
function registerPluginComponent(scope, elem, attrs, componentInfo) {
+ if (componentInfo.notFound) {
+ elem.empty();
+ return;
+ }
+
if (!componentInfo.Component.registered) {
var directiveName = attrs.$normalize(componentInfo.name);
var directiveFn = getPluginComponentDirective(componentInfo);
diff --git a/public/app/core/directives/rebuild_on_change.ts b/public/app/core/directives/rebuild_on_change.ts
index 6cc7ad899c1..847903f22ff 100644
--- a/public/app/core/directives/rebuild_on_change.ts
+++ b/public/app/core/directives/rebuild_on_change.ts
@@ -23,9 +23,11 @@ function getBlockNodes(nodes) {
return blockNodes || nodes;
}
-function rebuildOnChange($compile) {
+function rebuildOnChange($animate) {
return {
+ multiElement: true,
+ terminal: true,
transclude: true,
priority: 600,
restrict: 'E',
@@ -33,23 +35,31 @@ function rebuildOnChange($compile) {
var childScope, previousElements;
var uncompiledHtml;
- scope.$watch(attrs.property, function rebuildOnChangeAction(value) {
-
+ function cleanUp() {
if (childScope) {
childScope.$destroy();
childScope = null;
elem.empty();
}
+ }
- if (value || attrs.ignoreNull) {
- if (!childScope) {
- transclude(function(clone, newScope) {
- childScope = newScope;
- elem.append($compile(clone)(childScope));
- });
+ scope.$watch(attrs.property, function rebuildOnChangeAction(value, oldValue) {
+ if (value || attrs.showNull) {
+ // if same value and we have childscope
+ // ignore this double event
+ if (value === oldValue && childScope) {
+ return;
}
- }
+ cleanUp();
+ transclude(function(clone, newScope) {
+ childScope = newScope;
+ $animate.enter(clone, elem.parent(), elem);
+ });
+
+ } else {
+ cleanUp();
+ }
});
}
};
diff --git a/public/app/features/datasources/partials/edit.html b/public/app/features/datasources/partials/edit.html
index ad3473f0ea7..00706cb4de5 100644
--- a/public/app/features/datasources/partials/edit.html
+++ b/public/app/features/datasources/partials/edit.html
@@ -42,7 +42,7 @@