|
@@ -84,7 +84,10 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|
|
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);
|
|
|
|
|
|
|
+ .then(resolve)
|
|
|
|
|
+ .catch(err => {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
this.initSegments();
|
|
this.initSegments();
|
|
@@ -149,7 +152,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|
|
if (this.target.project.id !== 'default') {
|
|
if (this.target.project.id !== 'default') {
|
|
|
const metricTypes = await this.datasource.getMetricTypes(this.target.project.id);
|
|
const metricTypes = await this.datasource.getMetricTypes(this.target.project.id);
|
|
|
if (this.target.metricType === this.defaultDropdownValue && metricTypes.length > 0) {
|
|
if (this.target.metricType === this.defaultDropdownValue && metricTypes.length > 0) {
|
|
|
- this.$scope.$apply(() => (this.target.metricType = metricTypes[0].name));
|
|
|
|
|
|
|
+ this.$scope.$apply(() => (this.target.metricType = metricTypes[0].id));
|
|
|
}
|
|
}
|
|
|
return metricTypes.map(mt => ({ value: mt.id, text: mt.id }));
|
|
return metricTypes.map(mt => ({ value: mt.id, text: mt.id }));
|
|
|
} else {
|
|
} else {
|
|
@@ -183,7 +186,9 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async getGroupBys(segment, index, removeText?: string, removeUsed = true) {
|
|
async getGroupBys(segment, index, removeText?: string, removeUsed = true) {
|
|
|
- await this.initPromise;
|
|
|
|
|
|
|
+ if (!this.metricLabels || Object.keys(this.metricLabels).length === 0) {
|
|
|
|
|
+ await this.initPromise;
|
|
|
|
|
+ }
|
|
|
const metricLabels = Object.keys(this.metricLabels)
|
|
const metricLabels = Object.keys(this.metricLabels)
|
|
|
.filter(ml => {
|
|
.filter(ml => {
|
|
|
if (!removeUsed) {
|
|
if (!removeUsed) {
|
|
@@ -213,6 +218,11 @@ export class StackdriverQueryCtrl extends QueryCtrl {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ const noValueOrPlusButton = !segment || segment.type === 'plus-button';
|
|
|
|
|
+ if (noValueOrPlusButton && metricLabels.length === 0 && resourceLabels.length === 0) {
|
|
|
|
|
+ return Promise.resolve([]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.removeSegment.value = removeText || this.defaultRemoveGroupByValue;
|
|
this.removeSegment.value = removeText || this.defaultRemoveGroupByValue;
|
|
|
return Promise.resolve([...metricLabels, ...resourceLabels, this.removeSegment]);
|
|
return Promise.resolve([...metricLabels, ...resourceLabels, this.removeSegment]);
|
|
|
}
|
|
}
|