stackdriver: pass query definition from react, making it possible to use another definition than the query string only

This commit is contained in:
Erik Sundell 2018-11-02 11:58:50 +01:00
parent 5069f4afc9
commit 588c5c045a
5 changed files with 9 additions and 7 deletions

View File

@ -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() {

View File

@ -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();
};

View File

@ -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>

View File

@ -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) {

View File

@ -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;
}