Commit c2b72083 by Mitsuhiro Tanda

fix to match table column name and order

parent afce0feb
......@@ -153,6 +153,7 @@ export class PrometheusDatasource {
end: end,
responseListLength: responseList.length,
responseIndex: index,
refId: activeTargets[index].refId,
};
this.resultTransformer.transform(result, response, transformerOptions);
......
......@@ -8,7 +8,7 @@ export class ResultTransformer {
let prometheusResult = response.data.data.result;
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') {
let seriesList = [];
prometheusResult.sort(sortSeriesByLabel);
......@@ -58,7 +58,7 @@ export class ResultTransformer {
return { target: metricLabel, datapoints: dps };
}
transformMetricDataToTable(md, resultCount: number, resultIndex: number) {
transformMetricDataToTable(md, resultCount: number, refId: string) {
var table = new TableModel();
var i, j;
var metricLabels = {};
......@@ -83,7 +83,7 @@ export class ResultTransformer {
metricLabels[label] = labelIndex + 1;
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 });
// Populate rows, set value to empty string when label not present.
......
......@@ -154,6 +154,11 @@ class TablePanelCtrl extends MetricsPanelCtrl {
this.render();
}
moveQuery(target, direction) {
super.moveQuery(target, direction);
super.refresh();
}
exportCsv() {
var scope = this.$scope.$new(true);
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