TestData: attach labels to series results (#18653)

This commit is contained in:
Ryan McKinley
2019-08-21 07:50:13 -07:00
committed by GitHub
parent ffd630ad96
commit e6fbf358c8
4 changed files with 76 additions and 1 deletions

View File

@@ -14,7 +14,19 @@
<label class="gf-form-label query-keyword">Alias</label>
<input type="text" class="gf-form-input max-width-7" placeholder="optional" ng-model="ctrl.target.alias" ng-change="ctrl.refresh()" ng-model-onblur>
</div>
<div class="gf-form gf-form--grow">
<div ng-if="ctrl.showLabels" class="gf-form gf-form--grow">
<label class="gf-form-label query-keyword">
Labels
<info-popover mode="right-normal">
Set labels using a key=value syntax:<br/>
{key="value", key2="value"}<br/>
key="value", key2="value"<br/>
key=value, key2=value<br/>
</info-popover>
</label>
<input type="text" class="gf-form-input gf-form--grow" placeholder='key=value, key2=value2' ng-model="ctrl.target.labels" ng-change="ctrl.refresh()" ng-model-onblur>
</div>
<div ng-if="!ctrl.showLabels" class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div>
</div>
</div>

View File

@@ -18,6 +18,8 @@ export const defaultCSVWave: any = {
valuesCSV: '0,0,2,2,1,1',
};
const showLabelsFor = ['random_walk', 'predictable_pulse', 'predictable_csv_wave'];
export class TestDataQueryCtrl extends QueryCtrl {
static templateUrl = 'partials/query.editor.html';
@@ -27,6 +29,8 @@ export class TestDataQueryCtrl extends QueryCtrl {
newPointTime: any;
selectedPoint: any;
showLabels = false;
/** @ngInject */
constructor($scope: any, $injector: any) {
super($scope, $injector);
@@ -35,6 +39,7 @@ export class TestDataQueryCtrl extends QueryCtrl {
this.scenarioList = [];
this.newPointTime = dateTime();
this.selectedPoint = { text: 'Select point', value: null };
this.showLabels = showLabelsFor.includes(this.target.scenarioId);
}
getPoints() {
@@ -75,6 +80,7 @@ export class TestDataQueryCtrl extends QueryCtrl {
scenarioChanged() {
this.scenario = _.find(this.scenarioList, { id: this.target.scenarioId });
this.target.stringInput = this.scenario.stringInput;
this.showLabels = showLabelsFor.includes(this.target.scenarioId);
if (this.target.scenarioId === 'manual_entry') {
this.target.points = this.target.points || [];