Commit c2b72083 by Mitsuhiro Tanda

fix to match table column name and order

parent afce0feb
...@@ -153,6 +153,7 @@ export class PrometheusDatasource { ...@@ -153,6 +153,7 @@ export class PrometheusDatasource {
end: end, end: end,
responseListLength: responseList.length, responseListLength: responseList.length,
responseIndex: index, responseIndex: index,
refId: activeTargets[index].refId,
}; };
this.resultTransformer.transform(result, response, transformerOptions); this.resultTransformer.transform(result, response, transformerOptions);
......
...@@ -8,7 +8,7 @@ export class ResultTransformer { ...@@ -8,7 +8,7 @@ export class ResultTransformer {
let prometheusResult = response.data.data.result; let prometheusResult = response.data.data.result;
if (options.format === 'table') { if (options.format === 'table') {
result.push(this.transformMetricDataToTable(prometheusResult, options.responseListLength, options.responseIndex)); result.push(this.transformMetricDataToTable(prometheusResult, options.responseListLength, options.refId));
} else if (options.format === 'heatmap') { } else if (options.format === 'heatmap') {
let seriesList = []; let seriesList = [];
prometheusResult.sort(sortSeriesByLabel); prometheusResult.sort(sortSeriesByLabel);
...@@ -58,7 +58,7 @@ export class ResultTransformer { ...@@ -58,7 +58,7 @@ export class ResultTransformer {
return { target: metricLabel, datapoints: dps }; return { target: metricLabel, datapoints: dps };
} }
transformMetricDataToTable(md, resultCount: number, resultIndex: number) { transformMetricDataToTable(md, resultCount: number, refId: string) {
var table = new TableModel(); var table = new TableModel();
var i, j; var i, j;
var metricLabels = {}; var metricLabels = {};
...@@ -83,7 +83,7 @@ export class ResultTransformer { ...@@ -83,7 +83,7 @@ export class ResultTransformer {
metricLabels[label] = labelIndex + 1; metricLabels[label] = labelIndex + 1;
table.columns.push({ text: label }); table.columns.push({ text: label });
}); });
let valueText = resultCount > 1 ? `Value #${String.fromCharCode(65 + resultIndex)}` : 'Value'; let valueText = resultCount > 1 ? `Value #${refId}` : 'Value';
table.columns.push({ text: valueText }); table.columns.push({ text: valueText });
// Populate rows, set value to empty string when label not present. // Populate rows, set value to empty string when label not present.
......
...@@ -154,6 +154,11 @@ class TablePanelCtrl extends MetricsPanelCtrl { ...@@ -154,6 +154,11 @@ class TablePanelCtrl extends MetricsPanelCtrl {
this.render(); this.render();
} }
moveQuery(target, direction) {
super.moveQuery(target, direction);
super.refresh();
}
exportCsv() { exportCsv() {
var scope = this.$scope.$new(true); var scope = this.$scope.$new(true);
scope.tableData = this.renderer.render_values(); scope.tableData = this.renderer.render_values();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment