Commit 05dfccbb by Torkel Ödegaard

feat(plugins): moved annotation editor to new plugin component loader

parent fc829b32
...@@ -60,6 +60,17 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope) { ...@@ -60,6 +60,17 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope) {
}); });
}); });
} }
// QueryOptionsCtrl
case "annotations-query-ctrl": {
return System.import(scope.currentDatasource.meta.module).then(function(dsModule) {
return {
name: 'annotations-query-ctrl-' + scope.currentDatasource.meta.id,
bindings: {annotation: "=", datasource: "="},
attrs: {"annotation": "currentAnnotation", datasource: "currentDatasource"},
Component: dsModule.AnnotationsQueryCtrl,
};
});
}
// ConfigCtrl // ConfigCtrl
case 'datasource-config-ctrl': { case 'datasource-config-ctrl': {
return System.import(scope.datasourceMeta.module).then(function(dsModule) { return System.import(scope.datasourceMeta.module).then(function(dsModule) {
......
...@@ -2,7 +2,6 @@ define([ ...@@ -2,7 +2,6 @@ define([
'angular', 'angular',
'lodash', 'lodash',
'./editor_ctrl', './editor_ctrl',
'./query_editor'
], function (angular, _) { ], function (angular, _) {
'use strict'; 'use strict';
......
...@@ -91,8 +91,10 @@ ...@@ -91,8 +91,10 @@
</div> </div>
</div> </div>
<annotations-query-editor datasource="currentDatasource" annotation="currentAnnotation"> <rebuild-on-change property="currentAnnotation.datasource">
</annotations-query-editor> <plugin-component type="annotations-query-ctrl">
</plugin-component>
</rebuild-on-change>
<br> <br>
<button ng-show="mode === 'new'" type="button" class="btn btn-success" ng-click="add()">Add</button> <button ng-show="mode === 'new'" type="button" class="btn btn-success" ng-click="add()">Add</button>
......
///<reference path="../../headers/common.d.ts" />
import angular from 'angular';
/** @ngInject */
function annotationsQueryEditor(dynamicDirectiveSrv) {
return dynamicDirectiveSrv.create({
scope: {
annotation: "=",
datasource: "="
},
watchPath: "annotation.datasource",
directive: scope => {
return System.import(scope.datasource.meta.module).then(function(dsModule) {
return {
name: 'annotation-query-editor-' + scope.datasource.meta.id,
fn: dsModule.annotationsQueryEditor,
};
});
},
});
}
angular.module('grafana.directives').directive('annotationsQueryEditor', annotationsQueryEditor);
define([ define([
'./list_ctrl', './list_ctrl',
'./edit_ctrl', './edit_ctrl',
'./config_view',
], function () {}); ], function () {});
///<reference path="../../headers/common.d.ts" />
import angular from 'angular';
/** @ngInject */
function dsConfigView(dynamicDirectiveSrv) {
return dynamicDirectiveSrv.create({
scope: {
dsMeta: "=",
current: "="
},
watchPath: "dsMeta.module",
directive: scope => {
return System.import(scope.dsMeta.module).then(function(dsModule) {
return {
name: 'ds-config-' + scope.dsMeta.id,
fn: dsModule.configView,
};
});
},
});
}
angular.module('grafana.directives').directive('dsConfigView', dsConfigView);
...@@ -9,49 +9,15 @@ class GraphiteQueryOptionsCtrl { ...@@ -9,49 +9,15 @@ class GraphiteQueryOptionsCtrl {
static templateUrl = 'public/app/plugins/datasource/graphite/partials/query.options.html'; static templateUrl = 'public/app/plugins/datasource/graphite/partials/query.options.html';
} }
class AnnotationsQueryCtrl {
static templateUrl = 'public/app/plugins/datasource/graphite/partials/annotations.editor.html';
}
export { export {
GraphiteDatasource as Datasource, GraphiteDatasource as Datasource,
GraphiteQueryCtrl as QueryCtrl, GraphiteQueryCtrl as QueryCtrl,
GraphiteConfigCtrl as ConfigCtrl, GraphiteConfigCtrl as ConfigCtrl,
GraphiteQueryOptionsCtrl as QueryOptionsCtrl, GraphiteQueryOptionsCtrl as QueryOptionsCtrl,
AnnotationsQueryCtrl as AnnotationsQueryCtrl,
}; };
// define([
// './datasource',
// ],
// function (GraphiteDatasource) {
// 'use strict';
//
// function metricsQueryEditor() {
// return {
// controller: 'GraphiteQueryCtrl',
// templateUrl: 'public/app/plugins/datasource/graphite/partials/query.editor.html'
// };
// }
//
// function metricsQueryOptions() {
// return {templateUrl: 'public/app/plugins/datasource/graphite/partials/query.options.html'};
// }
//
// function annotationsQueryEditor() {
// return {templateUrl: 'public/app/plugins/datasource/graphite/partials/annotations.editor.html'};
// }
//
// function configView() {
// return {templateUrl: 'public/app/plugins/datasource/graphite/partials/config.html'};
// }
//
// function ConfigView() {
// }
// ConfigView.templateUrl = 'public/app/plugins/datasource/graphite/partials/config.html';
//
// return {
// Datasource: GraphiteDatasource,
// configView: configView,
// annotationsQueryEditor: annotationsQueryEditor,
// metricsQueryEditor: metricsQueryEditor,
// metricsQueryOptions: metricsQueryOptions,
// ConfigView: ConfigView
// };
// });
<div class="editor-row"> <div class="editor-row">
<div class="editor-option"> <div class="editor-option">
<label class="small">Graphite target expression</label> <label class="small">Graphite target expression</label>
<input type="text" class="span10" ng-model='annotation.target' placeholder=""></input> <input type="text" class="span10" ng-model='ctrl.annotation.target' placeholder=""></input>
</div> </div>
</div> </div>
<div class="editor-row"> <div class="editor-row">
<div class="editor-option"> <div class="editor-option">
<label class="small">Graphite event tags</label> <label class="small">Graphite event tags</label>
<input type="text" ng-model='annotation.tags' placeholder=""></input> <input type="text" ng-model='ctrl.annotation.tags' placeholder=""></input>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment