fix: Table panel now renders annotations correctly. Fixes #9842 (#9868)

This commit is contained in:
Marcus Efraimsson 2017-11-13 15:18:39 +01:00 committed by Torkel Ödegaard
parent ac8b20a60c
commit ecbe7d06a6
4 changed files with 16 additions and 4 deletions

View File

@ -104,7 +104,7 @@ export class TableRenderer {
return '-';
}
if (_.isString(v)) {
if (_.isString(v) || _.isArray(v)) {
return this.defaultCellFormatter(v, column.style);
}

View File

@ -14,9 +14,10 @@ describe('when rendering table', () => {
{text: 'United', unit: 'bps'},
{text: 'Sanitized'},
{text: 'Link'},
{text: 'Array'},
];
table.rows = [
[1388556366666, 1230, 40, undefined, "", "", "my.host.com", "host1"]
[1388556366666, 1230, 40, undefined, "", "", "my.host.com", "host1", ["value1", "value2"]]
];
var panel = {
@ -66,6 +67,12 @@ describe('when rendering table', () => {
linkUrl: "/dashboard?param=$__cell&param_1=$__cell_1&param_2=$__cell_2",
linkTooltip: "$__cell $__cell_1 $__cell_6",
linkTargetBlank: true
},
{
pattern: 'Array',
type: 'number',
unit: 'ms',
decimals: 3
}
]
};
@ -182,6 +189,11 @@ describe('when rendering table', () => {
`;
expect(normalize(html)).toBe(normalize(expectedHtml));
});
it('Array column should not use number as formatter', () => {
var html = renderer.renderCell(8, 0, ['value1', 'value2']);
expect(html).toBe('<td>value1, value2</td>');
});
});
});

View File

@ -154,7 +154,7 @@ describe('when transforming time series table', () => {
var rawData = {
annotations: [
{
min: 1000,
time: 1000,
text: 'hej',
tags: ['tags', 'asd'],
title: 'title',

View File

@ -124,7 +124,7 @@ transformers['annotations'] = {
for (var i = 0; i < data.annotations.length; i++) {
var evt = data.annotations[i];
model.rows.push([evt.min, evt.title, evt.text, evt.tags]);
model.rows.push([evt.time, evt.title, evt.text, evt.tags]);
}
}
};