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
494acddb
Commit
494acddb
authored
Mar 09, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get field mapping to actually work
parent
1cb03670
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
19 deletions
+34
-19
packages/grafana-ui/src/components/Table/Table.tsx
+14
-3
packages/grafana-ui/src/components/Table/TableCellBuilder.tsx
+3
-4
packages/grafana-ui/src/utils/index.ts
+1
-0
packages/grafana-ui/src/utils/stringUtils.ts
+13
-0
public/app/core/utils/kbn.ts
+3
-12
No files found.
packages/grafana-ui/src/components/Table/Table.tsx
View file @
494acddb
...
@@ -15,6 +15,7 @@ import { sortTableData } from '../../utils/processTimeSeries';
...
@@ -15,6 +15,7 @@ import { sortTableData } from '../../utils/processTimeSeries';
import
{
TableData
,
InterpolateFunction
}
from
'@grafana/ui'
;
import
{
TableData
,
InterpolateFunction
}
from
'@grafana/ui'
;
import
{
TableCellBuilder
,
ColumnStyle
,
getCellBuilder
,
TableCellBuilderOptions
}
from
'./TableCellBuilder'
;
import
{
TableCellBuilder
,
ColumnStyle
,
getCellBuilder
,
TableCellBuilderOptions
}
from
'./TableCellBuilder'
;
import
{
stringToJsRegex
}
from
'../../utils/index'
;
interface
ColumnInfo
{
interface
ColumnInfo
{
index
:
number
;
index
:
number
;
...
@@ -90,6 +91,8 @@ export class Table extends Component<Props, State> {
...
@@ -90,6 +91,8 @@ export class Table extends Component<Props, State> {
initColumns
(
props
:
Props
):
ColumnInfo
[]
{
initColumns
(
props
:
Props
):
ColumnInfo
[]
{
const
{
styles
,
data
}
=
props
;
const
{
styles
,
data
}
=
props
;
console
.
log
(
'STYLES'
,
styles
);
return
data
.
columns
.
map
((
col
,
index
)
=>
{
return
data
.
columns
.
map
((
col
,
index
)
=>
{
let
title
=
col
.
text
;
let
title
=
col
.
text
;
let
style
:
ColumnStyle
|
null
=
null
;
// ColumnStyle
let
style
:
ColumnStyle
|
null
=
null
;
// ColumnStyle
...
@@ -97,7 +100,7 @@ export class Table extends Component<Props, State> {
...
@@ -97,7 +100,7 @@ export class Table extends Component<Props, State> {
// Find the style based on the text
// Find the style based on the text
for
(
let
i
=
0
;
i
<
styles
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
styles
.
length
;
i
++
)
{
const
s
=
styles
[
i
];
const
s
=
styles
[
i
];
const
regex
=
'XXX'
;
//kbn.
stringToJsRegex(s.pattern);
const
regex
=
stringToJsRegex
(
s
.
pattern
);
if
(
title
.
match
(
regex
))
{
if
(
title
.
match
(
regex
))
{
style
=
s
;
style
=
s
;
if
(
s
.
alias
)
{
if
(
s
.
alias
)
{
...
@@ -170,14 +173,22 @@ export class Table extends Component<Props, State> {
...
@@ -170,14 +173,22 @@ export class Table extends Component<Props, State> {
const
{
rowIndex
,
columnIndex
,
key
,
parent
}
=
props
;
const
{
rowIndex
,
columnIndex
,
key
,
parent
}
=
props
;
const
{
showHeader
}
=
this
.
props
;
const
{
showHeader
}
=
this
.
props
;
const
{
data
}
=
this
.
state
;
const
{
data
}
=
this
.
state
;
const
column
=
this
.
columns
[
columnIndex
];
const
column
=
this
.
columns
[
columnIndex
];
if
(
!
column
)
{
if
(
!
column
)
{
return
<
div
>
XXX
</
div
>;
// NOT SURE HOW/WHY THIS HAPPENS!
// NOT SURE HOW/WHY THIS HAPPENS!
// Without it it will crash in storybook when you cycle up/down the # of columns
// this cell is never visible in the output?
return
(
<
div
key=
{
key
}
style=
{
props
.
style
}
>
XXXXX
</
div
>
);
}
}
const
realRowIndex
=
rowIndex
-
(
showHeader
?
1
:
0
);
const
realRowIndex
=
rowIndex
-
(
showHeader
?
1
:
0
);
const
isHeader
=
realRowIndex
<
0
;
const
isHeader
=
realRowIndex
<
0
;
const
row
=
isHeader
?
(
data
.
columns
as
any
[])
:
data
.
rows
[
realRowIndex
];
const
row
=
isHeader
?
data
.
columns
:
data
.
rows
[
realRowIndex
];
const
value
=
row
[
columnIndex
];
const
value
=
row
[
columnIndex
];
const
builder
=
isHeader
?
this
.
headerBuilder
:
column
.
builder
;
const
builder
=
isHeader
?
this
.
headerBuilder
:
column
.
builder
;
...
...
packages/grafana-ui/src/components/Table/TableCellBuilder.tsx
View file @
494acddb
...
@@ -41,12 +41,9 @@ export const simpleCellBuilder: TableCellBuilder = (cell: TableCellBuilderOption
...
@@ -41,12 +41,9 @@ export const simpleCellBuilder: TableCellBuilder = (cell: TableCellBuilderOption
//
//
// ***************************************************************************
// ***************************************************************************
// APP Imports!!!
// import kbn from 'app/core/utils/kbn';
// Made to match the existing (untyped) settings in the angular table
// Made to match the existing (untyped) settings in the angular table
export
interface
ColumnStyle
{
export
interface
ColumnStyle
{
pattern
?
:
string
;
pattern
:
string
;
alias
?:
string
;
alias
?:
string
;
colorMode
?:
'cell'
|
'value'
;
colorMode
?:
'cell'
|
'value'
;
...
@@ -89,6 +86,8 @@ export function getCellBuilder(schema: Column, style: ColumnStyle | null, props:
...
@@ -89,6 +86,8 @@ export function getCellBuilder(schema: Column, style: ColumnStyle | null, props:
}
}
if
(
style
.
type
===
'date'
)
{
if
(
style
.
type
===
'date'
)
{
console
.
log
(
'MAKE DATE Column'
,
schema
,
style
);
return
new
CellBuilderWithStyle
(
return
new
CellBuilderWithStyle
(
(
v
:
any
)
=>
{
(
v
:
any
)
=>
{
if
(
v
===
undefined
||
v
===
null
)
{
if
(
v
===
undefined
||
v
===
null
)
{
...
...
packages/grafana-ui/src/utils/index.ts
View file @
494acddb
...
@@ -2,4 +2,5 @@ export * from './processTimeSeries';
...
@@ -2,4 +2,5 @@ export * from './processTimeSeries';
export
*
from
'./valueFormats/valueFormats'
;
export
*
from
'./valueFormats/valueFormats'
;
export
*
from
'./colors'
;
export
*
from
'./colors'
;
export
*
from
'./namedColorsPalette'
;
export
*
from
'./namedColorsPalette'
;
export
*
from
'./stringUtils'
;
export
{
getMappedValue
}
from
'./valueMappings'
;
export
{
getMappedValue
}
from
'./valueMappings'
;
packages/grafana-ui/src/utils/stringUtils.ts
0 → 100644
View file @
494acddb
export
function
stringToJsRegex
(
str
:
string
):
RegExp
{
if
(
str
[
0
]
!==
'/'
)
{
return
new
RegExp
(
'^'
+
str
+
'$'
);
}
const
match
=
str
.
match
(
new
RegExp
(
'^/(.*?)/(g?i?m?y?)$'
));
if
(
!
match
)
{
throw
new
Error
(
`'
${
str
}
' is not a valid regular expression.`
);
}
return
new
RegExp
(
match
[
1
],
match
[
2
]);
}
public/app/core/utils/kbn.ts
View file @
494acddb
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
{
getValueFormat
,
getValueFormatterIndex
,
getValueFormats
}
from
'@grafana/ui'
;
import
{
getValueFormat
,
getValueFormatterIndex
,
getValueFormats
,
stringToJsRegex
}
from
'@grafana/ui'
;
const
kbn
:
any
=
{};
const
kbn
:
any
=
{};
...
@@ -229,17 +229,8 @@ kbn.slugifyForUrl = str => {
...
@@ -229,17 +229,8 @@ kbn.slugifyForUrl = str => {
};
};
kbn.stringToJsRegex = str => {
kbn.stringToJsRegex = str => {
if (str[0] !== '/') {
console.warn('Use grafana/ui stringToJsRegex');
return new RegExp('^' + str + '$');
return stringToJsRegex(str);
}
const match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$'));
if (!match) {
throw new Error(`'${str}' is not a valid regular expression.`);
}
return new RegExp(match[1], match[2]);
};
};
kbn.toFixed = (value, decimals) => {
kbn.toFixed = (value, decimals) => {
...
...
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