2018-10-14 14:14:11 -05:00
|
|
|
// Libraries
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
|
|
|
|
// Services & utils
|
|
|
|
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
|
|
|
|
|
|
|
|
// Types
|
2018-06-26 14:07:41 -05:00
|
|
|
import { PanelModel } from '../panel_model';
|
|
|
|
import { DashboardModel } from '../dashboard_model';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
panel: PanelModel;
|
|
|
|
dashboard: DashboardModel;
|
|
|
|
}
|
|
|
|
|
2018-10-14 14:14:11 -05:00
|
|
|
export class QueriesTab extends PureComponent<Props> {
|
2018-06-26 14:07:41 -05:00
|
|
|
element: any;
|
|
|
|
component: AngularComponent;
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
if (!this.element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-14 04:13:04 -05:00
|
|
|
const { panel, dashboard } = this.props;
|
|
|
|
|
2018-09-10 08:42:36 -05:00
|
|
|
const loader = getAngularLoader();
|
|
|
|
const template = '<metrics-tab />';
|
|
|
|
const scopeProps = {
|
2018-06-26 14:07:41 -05:00
|
|
|
ctrl: {
|
2018-10-14 04:13:04 -05:00
|
|
|
panel: panel,
|
|
|
|
dashboard: dashboard,
|
2018-10-14 14:14:11 -05:00
|
|
|
refresh: () => panel.refresh(),
|
2018-06-26 14:07:41 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
this.component = loader.load(this.element, scopeProps, template);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
if (this.component) {
|
|
|
|
this.component.destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <div ref={element => (this.element = element)} className="panel-height-helper" />;
|
|
|
|
}
|
|
|
|
}
|