mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: makes sure filter dropdown doesnt crash if clicked before values are loaded
This commit is contained in:
parent
fa6e31c6d5
commit
b30d3fb5a1
@ -1,6 +1,7 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { QueryCtrl } from 'app/plugins/sdk';
|
import { QueryCtrl } from 'app/plugins/sdk';
|
||||||
import appEvents from 'app/core/app_events';
|
import appEvents from 'app/core/app_events';
|
||||||
|
import { primitiveSymbol } from 'mobx/lib/utils/utils';
|
||||||
|
|
||||||
export interface QueryMeta {
|
export interface QueryMeta {
|
||||||
rawQuery: string;
|
rawQuery: string;
|
||||||
@ -30,6 +31,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|||||||
defaultFilterValue = 'select value';
|
defaultFilterValue = 'select value';
|
||||||
defaultRemoveGroupByValue = '-- remove group by --';
|
defaultRemoveGroupByValue = '-- remove group by --';
|
||||||
defaultRemoveFilterValue = '-- remove filter --';
|
defaultRemoveFilterValue = '-- remove filter --';
|
||||||
|
initPromise: Promise<any>;
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
project: {
|
project: {
|
||||||
@ -79,9 +81,12 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|||||||
this.panelCtrl.events.on('data-received', this.onDataReceived.bind(this), $scope);
|
this.panelCtrl.events.on('data-received', this.onDataReceived.bind(this), $scope);
|
||||||
this.panelCtrl.events.on('data-error', this.onDataError.bind(this), $scope);
|
this.panelCtrl.events.on('data-error', this.onDataError.bind(this), $scope);
|
||||||
|
|
||||||
|
this.initPromise = new Promise(async resolve => {
|
||||||
this.getCurrentProject()
|
this.getCurrentProject()
|
||||||
.then(this.getMetricTypes.bind(this))
|
.then(this.getMetricTypes.bind(this))
|
||||||
.then(this.getLabels.bind(this));
|
.then(this.getLabels.bind(this))
|
||||||
|
.then(resolve);
|
||||||
|
});
|
||||||
|
|
||||||
this.initSegments();
|
this.initSegments();
|
||||||
}
|
}
|
||||||
@ -178,7 +183,8 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|||||||
this.getLabels();
|
this.getLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
getGroupBys(segment, index, removeText?: string, removeUsed = true) {
|
async getGroupBys(segment, index, removeText?: string, removeUsed = true) {
|
||||||
|
await this.initPromise;
|
||||||
const metricLabels = Object.keys(this.metricLabels)
|
const metricLabels = Object.keys(this.metricLabels)
|
||||||
.filter(ml => {
|
.filter(ml => {
|
||||||
if (!removeUsed) {
|
if (!removeUsed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user