plugin_directive.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.directives');
  7. module.directive('pluginConfigLoader', function($compile) {
  8. return {
  9. restrict: 'E',
  10. link: function(scope, elem) {
  11. var directive = 'grafana-plugin-core';
  12. if (scope.current.module) {
  13. directive = 'grafana-plugin-'+scope.current.type;
  14. }
  15. scope.require([scope.current.module], function () {
  16. var panelEl = angular.element(document.createElement(directive));
  17. elem.append(panelEl);
  18. $compile(panelEl)(scope);
  19. });
  20. }
  21. };
  22. });
  23. module.directive('grafanaPluginCore', function() {
  24. return {
  25. restrict: 'E',
  26. templateUrl: 'app/features/org/partials/pluginConfigCore.html',
  27. transclude: true,
  28. link: function(scope, elem) {
  29. console.log("grafana plugin core", scope, elem);
  30. scope.update = function() {
  31. //Perform custom save events to the plugins own backend if needed.
  32. // call parent update to commit the change to the plugin object.
  33. // this will cause the page to reload.
  34. scope._update();
  35. };
  36. }
  37. };
  38. });
  39. });