mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: pass query definition from react, making it possible to use another definition than the query string only
This commit is contained in:
parent
5069f4afc9
commit
588c5c045a
@ -14,7 +14,7 @@ export default class DefaultTemplateQueryComponent extends PureComponent<Templat
|
||||
}
|
||||
|
||||
handleBlur(event) {
|
||||
this.props.onChange(event.target.value);
|
||||
this.props.onChange(event.target.value, event.target.value);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -107,8 +107,9 @@ export class VariableEditorCtrl {
|
||||
});
|
||||
};
|
||||
|
||||
$scope.onQueryChange = value => {
|
||||
$scope.current.query = value;
|
||||
$scope.onQueryChange = (query, definition) => {
|
||||
$scope.current.query = query;
|
||||
$scope.current.definition = definition;
|
||||
$scope.runQuery();
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
</span>
|
||||
</td>
|
||||
<td style="max-width: 200px;" ng-click="edit(variable)" class="pointer max-width">
|
||||
{{variable.query}}
|
||||
{{variable.definition ? variable.definition : variable.query}}
|
||||
</td>
|
||||
<td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
|
||||
<td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
|
||||
|
@ -96,7 +96,8 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
|
||||
|
||||
componentDidUpdate() {
|
||||
const { metricDescriptors, labels, metricTypes, services, ...queryModel } = this.state;
|
||||
this.props.onChange(queryModel);
|
||||
const queryName = this.queryTypes.find(q => q.value === this.state.selectedQueryType);
|
||||
this.props.onChange(queryModel, `Stackdriver - ${queryName.name}`);
|
||||
}
|
||||
|
||||
isLabelQuery(queryType) {
|
||||
|
@ -102,7 +102,7 @@ export interface PluginsState {
|
||||
|
||||
export interface TemplateQueryProps {
|
||||
query: any;
|
||||
onChange: (c: any) => void;
|
||||
onChange: (c: any, definition: string) => void;
|
||||
datasource: any;
|
||||
// datasource: StackdriverDatasource;
|
||||
definition: string;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user