Sfoglia il codice sorgente

stackdriver: move response parsing to datasource file

Erik Sundell 7 anni fa
parent
commit
cbb663015e

+ 3 - 1
public/app/plugins/datasource/stackdriver/datasource.ts

@@ -70,7 +70,7 @@ export default class StackdriverDatasource {
   }
   }
 
 
   async getLabels(metricType, refId) {
   async getLabels(metricType, refId) {
-    return await this.getTimeSeries({
+    const response = await this.getTimeSeries({
       targets: [
       targets: [
         {
         {
           refId: refId,
           refId: refId,
@@ -84,6 +84,8 @@ export default class StackdriverDatasource {
       ],
       ],
       range: this.timeSrv.timeRange(),
       range: this.timeSrv.timeRange(),
     });
     });
+
+    return response.results[refId];
   }
   }
 
 
   interpolateGroupBys(groupBys: string[], scopedVars): string[] {
   interpolateGroupBys(groupBys: string[], scopedVars): string[] {

+ 4 - 4
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts

@@ -150,10 +150,10 @@ export class StackdriverFilterCtrl {
   async getLabels() {
   async getLabels() {
     this.loadLabelsPromise = new Promise(async resolve => {
     this.loadLabelsPromise = new Promise(async resolve => {
       try {
       try {
-        const data = await this.datasource.getLabels(this.target.metricType, this.target.refId);
-        this.metricLabels = data.results[this.target.refId].meta.metricLabels;
-        this.resourceLabels = data.results[this.target.refId].meta.resourceLabels;
-        this.resourceTypes = data.results[this.target.refId].meta.resourceTypes;
+        const { meta } = await this.datasource.getLabels(this.target.metricType, this.target.refId);
+        this.metricLabels = meta.metricLabels;
+        this.resourceLabels = meta.resourceLabels;
+        this.resourceTypes = meta.resourceTypes;
         resolve();
         resolve();
       } catch (error) {
       } catch (error) {
         if (error.data && error.data.message) {
         if (error.data && error.data.message) {