panel_loader.ts 604 B

12345678910111213141516171819202122
  1. ///<reference path="../../headers/common.d.ts" />
  2. import angular from 'angular';
  3. import config from 'app/core/config';
  4. /** @ngInject */
  5. function panelLoader($parse, dynamicDirectiveSrv) {
  6. return dynamicDirectiveSrv.create({
  7. directive: scope => {
  8. let modulePath = config.panels[scope.panel.type].module;
  9. return System.import(modulePath).then(function(panelModule) {
  10. return {
  11. name: 'panel-directive-' + scope.panel.type,
  12. fn: panelModule.panel,
  13. };
  14. });
  15. },
  16. });
  17. }
  18. angular.module('grafana.directives').directive('panelLoader', panelLoader);