Commit 1969ad41 by Erik Sundell

stackdriver: refactor stackdriver query ctrl

parent 4f7d3fcc
......@@ -14,13 +14,13 @@ async function loadComponent(module) {
}
/** @ngInject */
function pluginTemplateQueryComponentLoader(datasourceSrv) {
function pluginTemplateQueryComponentLoader() {
return {
restrict: 'E',
link: async (scope, elem) => {
const Component = await loadComponent(scope.currentDatasource.meta.module);
const props = {
datasourceSrv,
datasource: scope.currentDatasource,
query: scope.current.query,
onChange: scope.onQueryChange,
};
......
import React, { PureComponent } from 'react';
import DatasourceSrv from 'app/features/plugins/datasource_srv';
import StackdriverDatasource from './datasource';
interface Props {
datasource: StackdriverDatasource;
query: string;
datasourceSrv: DatasourceSrv;
isValid: any;
onChange: (c: string) => void;
}
export class StackdriverTemplateQueryCtrl extends PureComponent<Props> {
export class StackdriverTemplateQueryCtrl extends PureComponent<Props, any> {
constructor(props) {
super(props);
}
componentDidMount() {
console.log('componentDidMount');
async componentDidMount() {
const metricDescriptors = await this.props.datasource.getMetricTypes(this.props.datasource.projectName);
console.log(metricDescriptors);
}
render() {
return <h1>Hello Stackdriver Template Query</h1>;
return (
<div className="gf-form">
<span className="gf-form-label width-7">Query</span>
<input
type="text"
className="gf-form-input"
// value={this.state.value}
// onChange={this.handleChange}
// onBlur={this.handleBlur}
placeholder="metric name or tags query"
required
/>
</div>
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment