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