2017-12-19 09:06:54 -06:00
|
|
|
import angular from "angular";
|
|
|
|
import coreModule from "app/core/core_module";
|
2017-10-09 13:38:48 -05:00
|
|
|
|
|
|
|
export interface AttachedPanel {
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PanelLoader {
|
|
|
|
/** @ngInject */
|
2017-12-19 09:06:54 -06:00
|
|
|
constructor(private $compile, private $rootScope) {}
|
2017-10-09 13:38:48 -05:00
|
|
|
|
|
|
|
load(elem, panel, dashboard): AttachedPanel {
|
2017-12-19 09:06:54 -06:00
|
|
|
var template =
|
|
|
|
'<plugin-component type="panel" class="panel-height-helper"></plugin-component>';
|
2017-10-09 13:38:48 -05:00
|
|
|
var panelScope = this.$rootScope.$new();
|
|
|
|
panelScope.panel = panel;
|
|
|
|
panelScope.dashboard = dashboard;
|
|
|
|
|
|
|
|
const compiledElem = this.$compile(template)(panelScope);
|
|
|
|
const rootNode = angular.element(elem);
|
|
|
|
rootNode.append(compiledElem);
|
|
|
|
|
|
|
|
return {
|
|
|
|
destroy: () => {
|
|
|
|
panelScope.$destroy();
|
|
|
|
compiledElem.remove();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 09:06:54 -06:00
|
|
|
coreModule.service("panelLoader", PanelLoader);
|