Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5775c0a3
Commit
5775c0a3
authored
Feb 07, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(table): remove option to disable html encoding
parent
d750908e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
29 deletions
+11
-29
public/app/plugins/panel/table/renderer.ts
+10
-21
public/app/plugins/panel/table/specs/renderer_specs.ts
+1
-8
No files found.
public/app/plugins/panel/table/renderer.ts
View file @
5775c0a3
...
...
@@ -4,8 +4,6 @@ import _ from 'lodash';
import
moment
from
'moment'
;
import
kbn
from
'app/core/utils/kbn'
;
export
class
TableRenderer
{
formaters
:
any
[];
colorState
:
any
;
...
...
@@ -26,27 +24,21 @@ export class TableRenderer {
return
_
.
first
(
style
.
colors
);
}
defaultCellFormater
(
escapeHtml
=
true
)
{
return
function
(
v
)
{
if
(
v
===
null
||
v
===
void
0
||
v
===
undefined
)
{
defaultCellFormater
(
value
)
{
if
(
value
===
null
||
value
===
void
0
||
value
===
undefined
)
{
return
''
;
}
if
(
_
.
isArray
(
v
))
{
v
=
v
.
join
(
', '
);
if
(
_
.
isArray
(
value
))
{
v
alue
=
value
.
join
(
', '
);
}
if
(
_
.
isString
(
v
)
&&
escapeHtml
)
{
v
=
encodeHtml
(
v
);
}
return
v
;
};
return
value
;
}
createColumnFormater
(
style
)
{
if
(
!
style
)
{
return
this
.
defaultCellFormater
()
;
return
this
.
defaultCellFormater
;
}
if
(
style
.
type
===
'date'
)
{
...
...
@@ -69,7 +61,7 @@ export class TableRenderer {
}
if
(
_
.
isString
(
v
))
{
return
encodeHtml
(
v
)
;
return
v
;
}
if
(
style
.
colorMode
)
{
...
...
@@ -80,11 +72,7 @@ export class TableRenderer {
};
}
if
(
style
.
type
===
'string'
)
{
return
this
.
defaultCellFormater
(
style
.
escapeHtml
);
}
return
this
.
defaultCellFormater
();
return
this
.
defaultCellFormater
;
}
formatColumnValue
(
colIndex
,
value
)
{
...
...
@@ -102,12 +90,13 @@ export class TableRenderer {
}
}
this
.
formaters
[
colIndex
]
=
this
.
defaultCellFormater
()
;
this
.
formaters
[
colIndex
]
=
this
.
defaultCellFormater
;
return
this
.
formaters
[
colIndex
](
value
);
}
renderCell
(
columnIndex
,
value
,
addWidthHack
=
false
)
{
value
=
this
.
formatColumnValue
(
columnIndex
,
value
);
value
=
encodeHtml
(
value
);
var
style
=
''
;
if
(
this
.
colorState
.
cell
)
{
style
=
' style="background-color:'
+
this
.
colorState
.
cell
+
';color: white"'
;
...
...
public/app/plugins/panel/table/specs/renderer_specs.ts
View file @
5775c0a3
...
...
@@ -41,12 +41,10 @@ describe('when rendering table', () => {
{
pattern
:
'String'
,
type
:
'string'
,
escapeHtml
:
true
,
},
{
pattern
:
'UnescapedString'
,
type
:
'string'
,
escapeHtml
:
false
,
type
:
'string'
}
]
};
...
...
@@ -98,11 +96,6 @@ describe('when rendering table', () => {
expect
(
html
).
to
.
be
(
'<td>&breaking <br /> the <br /> row</td>'
);
});
it
(
'string style with escape html false should return html'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
5
,
"&breaking <br /> the <br /> row"
);
expect
(
html
).
to
.
be
(
'<td>&breaking <br /> the <br /> row</td>'
);
});
it
(
'undefined value should render as -'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
3
,
undefined
);
expect
(
html
).
to
.
be
(
'<td></td>'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment