query_editor.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ///<reference path="../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. /** @ngInject */
  4. function metricsQueryEditor(dynamicDirectiveSrv, datasourceSrv) {
  5. return dynamicDirectiveSrv.create({
  6. watch: "panel.datasource",
  7. directive: scope => {
  8. let datasource = scope.target.datasource || scope.panel.datasource;
  9. return datasourceSrv.get(datasource).then(ds => {
  10. scope.datasource = ds;
  11. return System.import(ds.meta.module).then(dsModule => {
  12. return {
  13. name: 'metrics-query-editor-' + ds.meta.id,
  14. fn: dsModule.metricsQueryEditor,
  15. };
  16. });
  17. });
  18. }
  19. });
  20. }
  21. /** @ngInject */
  22. function metricsQueryOptions(dynamicDirectiveSrv, datasourceSrv) {
  23. return dynamicDirectiveSrv.create({
  24. watch: "panel.datasource",
  25. directive: scope => {
  26. return datasourceSrv.get(scope.panel.datasource).then(ds => {
  27. return System.import(ds.meta.module).then(dsModule => {
  28. return {
  29. name: 'metrics-query-options-' + ds.meta.id,
  30. fn: dsModule.metricsQueryOptions
  31. };
  32. });
  33. });
  34. }
  35. });
  36. }
  37. angular.module('grafana.directives')
  38. .directive('metricsQueryEditor', metricsQueryEditor)
  39. .directive('metricsQueryOptions', metricsQueryOptions);