diff --git a/src/directives/metric_name_field.ts b/src/directives/metric_name_field.ts index fb77bfc..e3f3877 100644 --- a/src/directives/metric_name_field.ts +++ b/src/directives/metric_name_field.ts @@ -20,6 +20,11 @@ export class MetricNameFieldCtrl { this.$scope = $scope; this.$q = $q; this.uiSegmentSrv = uiSegmentSrv; + if (this.$scope.ctrl.target) { + if (this.$scope.ctrl.target.query) { + this.value = this.$scope.ctrl.target.query.metricName; + } + } this.promiseUtils = new PromiseUtils($q); this.segment = this.value ? uiSegmentSrv.newSegment(this.value) : uiSegmentSrv.newSelectMetric(); this.aliasAddedVisible = !_.isNil(this.alias); diff --git a/src/directives/tags_select.ts b/src/directives/tags_select.ts index 5408172..8470cf3 100644 --- a/src/directives/tags_select.ts +++ b/src/directives/tags_select.ts @@ -5,13 +5,19 @@ export class TagsSelectCtrl { public availableValues: string[]; public selectedValues: string[]; public segments: any[]; + public $scope: any; /** @ngInject **/ - constructor(private uiSegmentSrv) { + constructor( $scope, private uiSegmentSrv) { + this.$scope = $scope; this.selectedValues = this.selectedValues || []; this.availableValues = this.tagValues; this.segments = this.selectedValues.map((tagValue) => this.uiSegmentSrv.newSegment(tagValue)); this.segments.push(this.uiSegmentSrv.newPlusButton()); + setTimeout( ( ) => { this.segments = this.selectedValues.map( ( tagValue ) => this.uiSegmentSrv.newSegment(tagValue) ); + this.segments.push(this.uiSegmentSrv.newPlusButton()); + this.$scope.$apply(); + }, 500); } public onChange(): void {