Commit ff759b0e by Dan Cech

send prefix when auto-completing tags

parent d8f2a207
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
</div> </div>
<div ng-if="ctrl.queryModel.seriesByTagUsed" ng-repeat="segment in ctrl.addTagSegments" role="menuitem" class="gf-form"> <div ng-if="ctrl.queryModel.seriesByTagUsed" ng-repeat="segment in ctrl.addTagSegments" role="menuitem" class="gf-form">
<metric-segment segment="segment" get-options="ctrl.getTagsAsSegments()" on-change="ctrl.addNewTag(segment)" /> <metric-segment segment="segment" get-options="ctrl.getTagsAsSegments($query)" on-change="ctrl.addNewTag(segment)" />
</div> </div>
<div ng-if="!ctrl.queryModel.seriesByTagUsed" ng-repeat="segment in ctrl.segments" role="menuitem" class="gf-form"> <div ng-if="!ctrl.queryModel.seriesByTagUsed" ng-repeat="segment in ctrl.segments" role="menuitem" class="gf-form">
<metric-segment segment="segment" get-options="ctrl.getAltSegments($index)" on-change="ctrl.segmentValueChanged(segment, $index)" /> <metric-segment segment="segment" get-options="ctrl.getAltSegments($index, $query)" on-change="ctrl.segmentValueChanged(segment, $index)" />
</div> </div>
<div ng-if="ctrl.paused" class="gf-form"> <div ng-if="ctrl.paused" class="gf-form">
......
...@@ -105,7 +105,7 @@ export class GraphiteQueryCtrl extends QueryCtrl { ...@@ -105,7 +105,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
}); });
} }
getAltSegments(index) { getAltSegments(index, prefix) {
var query = index === 0 ? '*' : this.queryModel.getSegmentPathUpTo(index) + '.*'; var query = index === 0 ? '*' : this.queryModel.getSegmentPathUpTo(index) + '.*';
var options = { var options = {
range: this.panelCtrl.range, range: this.panelCtrl.range,
...@@ -122,7 +122,7 @@ export class GraphiteQueryCtrl extends QueryCtrl { ...@@ -122,7 +122,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
}); });
}); });
if (altSegments.length === 0) { if (index > 0 && altSegments.length === 0) {
return altSegments; return altSegments;
} }
...@@ -159,7 +159,7 @@ export class GraphiteQueryCtrl extends QueryCtrl { ...@@ -159,7 +159,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
if (this.supportsTags && index === 0) { if (this.supportsTags && index === 0) {
this.removeTaggedEntry(altSegments); this.removeTaggedEntry(altSegments);
return this.addAltTagSegments(index, altSegments); return this.addAltTagSegments(prefix, altSegments);
} else { } else {
return altSegments; return altSegments;
} }
...@@ -169,8 +169,8 @@ export class GraphiteQueryCtrl extends QueryCtrl { ...@@ -169,8 +169,8 @@ export class GraphiteQueryCtrl extends QueryCtrl {
}); });
} }
addAltTagSegments(index, altSegments) { addAltTagSegments(prefix, altSegments) {
return this.getTagsAsSegments().then(tagSegments => { return this.getTagsAsSegments(prefix).then(tagSegments => {
tagSegments = _.map(tagSegments, segment => { tagSegments = _.map(tagSegments, segment => {
segment.value = TAG_PREFIX + segment.value; segment.value = TAG_PREFIX + segment.value;
return segment; return segment;
...@@ -315,9 +315,9 @@ export class GraphiteQueryCtrl extends QueryCtrl { ...@@ -315,9 +315,9 @@ export class GraphiteQueryCtrl extends QueryCtrl {
}); });
} }
getTagsAsSegments() { getTagsAsSegments(tagPrefix) {
let tagExpressions = this.queryModel.renderTagExpressions(); let tagExpressions = this.queryModel.renderTagExpressions();
return this.datasource.getTagsAutoComplete(tagExpressions).then(values => { return this.datasource.getTagsAutoComplete(tagExpressions, tagPrefix).then(values => {
return _.map(values, val => { return _.map(values, val => {
return this.uiSegmentSrv.newSegment({ return this.uiSegmentSrv.newSegment({
value: val.text, value: val.text,
......
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