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';
...
@@ -4,8 +4,6 @@ import _ from 'lodash';
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
kbn
from
'app/core/utils/kbn'
;
import
kbn
from
'app/core/utils/kbn'
;
export
class
TableRenderer
{
export
class
TableRenderer
{
formaters
:
any
[];
formaters
:
any
[];
colorState
:
any
;
colorState
:
any
;
...
@@ -26,27 +24,21 @@ export class TableRenderer {
...
@@ -26,27 +24,21 @@ export class TableRenderer {
return
_
.
first
(
style
.
colors
);
return
_
.
first
(
style
.
colors
);
}
}
defaultCellFormater
(
escapeHtml
=
true
)
{
defaultCellFormater
(
value
)
{
return
function
(
v
)
{
if
(
value
===
null
||
value
===
void
0
||
value
===
undefined
)
{
if
(
v
===
null
||
v
===
void
0
||
v
===
undefined
)
{
return
''
;
return
''
;
}
}
if
(
_
.
isArray
(
v
))
{
if
(
_
.
isArray
(
value
))
{
v
=
v
.
join
(
', '
);
v
alue
=
value
.
join
(
', '
);
}
}
if
(
_
.
isString
(
v
)
&&
escapeHtml
)
{
return
value
;
v
=
encodeHtml
(
v
);
}
return
v
;
};
}
}
createColumnFormater
(
style
)
{
createColumnFormater
(
style
)
{
if
(
!
style
)
{
if
(
!
style
)
{
return
this
.
defaultCellFormater
()
;
return
this
.
defaultCellFormater
;
}
}
if
(
style
.
type
===
'date'
)
{
if
(
style
.
type
===
'date'
)
{
...
@@ -69,7 +61,7 @@ export class TableRenderer {
...
@@ -69,7 +61,7 @@ export class TableRenderer {
}
}
if
(
_
.
isString
(
v
))
{
if
(
_
.
isString
(
v
))
{
return
encodeHtml
(
v
)
;
return
v
;
}
}
if
(
style
.
colorMode
)
{
if
(
style
.
colorMode
)
{
...
@@ -80,11 +72,7 @@ export class TableRenderer {
...
@@ -80,11 +72,7 @@ export class TableRenderer {
};
};
}
}
if
(
style
.
type
===
'string'
)
{
return
this
.
defaultCellFormater
;
return
this
.
defaultCellFormater
(
style
.
escapeHtml
);
}
return
this
.
defaultCellFormater
();
}
}
formatColumnValue
(
colIndex
,
value
)
{
formatColumnValue
(
colIndex
,
value
)
{
...
@@ -102,12 +90,13 @@ export class TableRenderer {
...
@@ -102,12 +90,13 @@ export class TableRenderer {
}
}
}
}
this
.
formaters
[
colIndex
]
=
this
.
defaultCellFormater
()
;
this
.
formaters
[
colIndex
]
=
this
.
defaultCellFormater
;
return
this
.
formaters
[
colIndex
](
value
);
return
this
.
formaters
[
colIndex
](
value
);
}
}
renderCell
(
columnIndex
,
value
,
addWidthHack
=
false
)
{
renderCell
(
columnIndex
,
value
,
addWidthHack
=
false
)
{
value
=
this
.
formatColumnValue
(
columnIndex
,
value
);
value
=
this
.
formatColumnValue
(
columnIndex
,
value
);
value
=
encodeHtml
(
value
);
var
style
=
''
;
var
style
=
''
;
if
(
this
.
colorState
.
cell
)
{
if
(
this
.
colorState
.
cell
)
{
style
=
' style="background-color:'
+
this
.
colorState
.
cell
+
';color: white"'
;
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', () => {
...
@@ -41,12 +41,10 @@ describe('when rendering table', () => {
{
{
pattern
:
'String'
,
pattern
:
'String'
,
type
:
'string'
,
type
:
'string'
,
escapeHtml
:
true
,
},
},
{
{
pattern
:
'UnescapedString'
,
pattern
:
'UnescapedString'
,
type
:
'string'
,
type
:
'string'
escapeHtml
:
false
,
}
}
]
]
};
};
...
@@ -98,11 +96,6 @@ describe('when rendering table', () => {
...
@@ -98,11 +96,6 @@ describe('when rendering table', () => {
expect
(
html
).
to
.
be
(
'<td>&breaking <br /> the <br /> row</td>'
);
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 -'
,
()
=>
{
it
(
'undefined value should render as -'
,
()
=>
{
var
html
=
renderer
.
renderCell
(
3
,
undefined
);
var
html
=
renderer
.
renderCell
(
3
,
undefined
);
expect
(
html
).
to
.
be
(
'<td></td>'
);
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