From 1deeef9e91a4c34087afd177a1763401ad33e159 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 27 Jun 2017 13:38:49 +0300 Subject: [PATCH] Table panel: add option for preserving text formatting (#8708) * table_panel: add option for preserving text formatting * table_panel: fix undefined style error * table_panel: fix class adding (add space before 'class') * table_panel: aligin Type options labels --- public/app/plugins/panel/table/column_options.html | 13 ++++++++----- public/app/plugins/panel/table/renderer.ts | 8 +++++++- public/sass/components/_panel_table.scss | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/panel/table/column_options.html b/public/app/plugins/panel/table/column_options.html index 35fa4ac2d8b..db4758ab8f3 100644 --- a/public/app/plugins/panel/table/column_options.html +++ b/public/app/plugins/panel/table/column_options.html @@ -33,27 +33,30 @@
Type
- +
- +
- + +
+
+
- +
- +
diff --git a/public/app/plugins/panel/table/renderer.ts b/public/app/plugins/panel/table/renderer.ts index ae56e8dff12..dc031df8d1e 100644 --- a/public/app/plugins/panel/table/renderer.ts +++ b/public/app/plugins/panel/table/renderer.ts @@ -130,6 +130,7 @@ export class TableRenderer { renderCell(columnIndex, value, addWidthHack = false) { value = this.formatColumnValue(columnIndex, value); var style = ''; + var cellClass = ''; if (this.colorState.cell) { style = ' style="background-color:' + this.colorState.cell + ';color: white"'; this.colorState.cell = null; @@ -153,7 +154,12 @@ export class TableRenderer { this.table.columns[columnIndex].hidden = false; } - return '' + value + widthHack + ''; + var columnStyle = this.table.columns[columnIndex].style; + if (columnStyle && columnStyle.preserveFormat) { + cellClass = ' class="table-panel-cell-pre" '; + } + + return '' + value + widthHack + ''; } render(page) { diff --git a/public/sass/components/_panel_table.scss b/public/sass/components/_panel_table.scss index ec0c73e2ec7..17dbc910b2d 100644 --- a/public/sass/components/_panel_table.scss +++ b/public/sass/components/_panel_table.scss @@ -72,6 +72,10 @@ &:last-child { border-right: none; } + + &.table-panel-cell-pre { + white-space: pre; + } } }