mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
use plugin_loader directly instead of using the wrapper
This commit is contained in:
parent
eaf9a0b39a
commit
fae3ae2580
@ -1,13 +1,16 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
|
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
|
||||||
import 'app/features/panel/metrics_wrapper';
|
import { Emitter } from 'app/core/utils/emitter';
|
||||||
import { DataQuery } from 'app/types';
|
import { DataQuery } from 'app/types';
|
||||||
|
import 'app/features/plugins/plugin_loader';
|
||||||
|
|
||||||
interface QueryEditorProps {
|
interface QueryEditorProps {
|
||||||
datasource: any;
|
datasource: any;
|
||||||
error?: string | JSX.Element;
|
error?: string | JSX.Element;
|
||||||
onExecuteQuery?: () => void;
|
onExecuteQuery?: () => void;
|
||||||
onQueryChange?: (value: DataQuery, override?: boolean) => void;
|
onQueryChange?: (value: DataQuery, override?: boolean) => void;
|
||||||
|
initialQuery: DataQuery;
|
||||||
|
exploreEvents: Emitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
|
export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
|
||||||
@ -19,27 +22,26 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { datasource } = this.props;
|
const { datasource, initialQuery, exploreEvents } = this.props;
|
||||||
const loader = getAngularLoader();
|
const loader = getAngularLoader();
|
||||||
const template = '<metrics-wrapper />';
|
const template = '<plugin-component type="query-ctrl"> </plugin-component>';
|
||||||
const target = { datasource: datasource.name };
|
const target = { datasource: datasource.name };
|
||||||
// const changeableTarget = onChange(target, () => console.log(target));
|
|
||||||
// const changeable = onChange(target, () => console.log(target));
|
|
||||||
const scopeProps = {
|
const scopeProps = {
|
||||||
target, //: changeable,
|
target,
|
||||||
ctrl: {
|
ctrl: {
|
||||||
refresh: () => {
|
refresh: () => {
|
||||||
this.props.onQueryChange({ refId: 'TEST', ...target }, false);
|
this.props.onQueryChange({ refId: initialQuery.refId, ...target }, false);
|
||||||
this.props.onExecuteQuery();
|
this.props.onExecuteQuery();
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
on: () => {},
|
on: () => exploreEvents,
|
||||||
},
|
},
|
||||||
panel: {
|
panel: {
|
||||||
datasource,
|
datasource,
|
||||||
|
targets: [{}],
|
||||||
},
|
},
|
||||||
dashboard: {
|
dashboard: {
|
||||||
getNextQueryLetter: x => 'TEST',
|
getNextQueryLetter: x => '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
import coreModule from 'app/core/core_module';
|
|
||||||
|
|
||||||
/** @ngInject */
|
|
||||||
export function metricsWrapperDirective() {
|
|
||||||
'use strict';
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
scope: true,
|
|
||||||
template: `<plugin-component type="query-ctrl"> </plugin-component>`,
|
|
||||||
link: $scope => {
|
|
||||||
$scope.panelCtrl = $scope.ctrl;
|
|
||||||
$scope.ctrl = $scope.panelCtrl;
|
|
||||||
$scope.panel = $scope.panelCtrl.panel;
|
|
||||||
$scope.panel.datasource = $scope.panel.datasource || null;
|
|
||||||
$scope.panel.targets = $scope.panel.targets || [{}];
|
|
||||||
$scope.events = $scope.panelCtrl.events;
|
|
||||||
$scope.refresh = $scope.panelCtrl.refresh;
|
|
||||||
$scope.dashboard = $scope.panelCtrl.dashboard;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
coreModule.directive('metricsWrapper', metricsWrapperDirective);
|
|
Loading…
Reference in New Issue
Block a user