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
00a479de
Commit
00a479de
authored
Nov 13, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(tablepanel): renamed some table panel schema things
parent
32f9f8fc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
44 deletions
+77
-44
public/app/panels/table/controller.ts
+9
-2
public/app/panels/table/editor.html
+22
-22
public/app/panels/table/editor.ts
+12
-12
public/app/panels/table/renderer.ts
+2
-2
public/app/panels/table/specs/renderer_specs.ts
+1
-1
public/app/panels/table/specs/transformers_specs.ts
+27
-1
public/app/panels/table/transformers.ts
+4
-4
No files found.
public/app/panels/table/controller.ts
View file @
00a479de
...
...
@@ -29,7 +29,7 @@ export class TablePanelCtrl {
transform
:
'timeseries_to_rows'
,
pageSize
:
50
,
showHeader
:
true
,
column
s
:
[
style
s
:
[
{
type
:
'date'
,
pattern
:
'Time'
,
...
...
@@ -45,13 +45,20 @@ export class TablePanelCtrl {
thresholds
:
[],
}
],
field
s
:
[],
column
s
:
[],
scroll
:
true
,
fontSize
:
'100%'
,
sort
:
{
col
:
0
,
desc
:
true
},
};
$scope
.
init
=
function
()
{
if
(
$scope
.
panel
.
styles
===
void
0
)
{
$scope
.
panel
.
styles
=
$scope
.
panel
.
columns
;
$scope
.
panel
.
columns
=
$scope
.
panel
.
fields
;
delete
$scope
.
panel
.
columns
;
delete
$scope
.
panel
.
fields
;
}
_
.
defaults
(
$scope
.
panel
,
panelDefaults
);
panelSrv
.
init
(
$scope
);
...
...
public/app/panels/table/editor.html
View file @
00a479de
...
...
@@ -19,15 +19,15 @@
<div
class=
"tight-form"
ng-if=
"panel.transform === 'json'"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 140px"
>
Field
s
Column
s
</li>
<li
class=
"tight-form-item"
ng-repeat=
"
field in panel.field
s"
>
<i
class=
"pointer fa fa-remove"
ng-click=
"remove
JsonField(field
)"
></i>
<li
class=
"tight-form-item"
ng-repeat=
"
column in panel.column
s"
>
<i
class=
"pointer fa fa-remove"
ng-click=
"remove
Column(column
)"
></i>
<span>
{{
field
.name}}
{{
column
.name}}
</span>
</li>
<li
class=
"dropdown"
dropdown-typeahead=
"
jsonFieldsMenu"
dropdown-typeahead-on-select=
"addJsonField
($item, $subItem)"
>
<li
class=
"dropdown"
dropdown-typeahead=
"
columnsMenu"
dropdown-typeahead-on-select=
"addColumn
($item, $subItem)"
>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
@@ -67,11 +67,11 @@
<h5>
Column Styles
</h5>
<div
class=
"tight-form-container"
>
<div
ng-repeat=
"
column in panel.column
s"
>
<div
ng-repeat=
"
style in panel.style
s"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list pull-right"
>
<li
class=
"tight-form-item last"
>
<i
class=
"fa fa-remove pointer"
ng-click=
"removeColumnStyle(
column
)"
></i>
<i
class=
"fa fa-remove pointer"
ng-click=
"removeColumnStyle(
style
)"
></i>
</li>
</ul>
...
...
@@ -80,38 +80,38 @@
Name or regex
</li>
<li>
<input
type=
"text"
ng-model=
"
column
.pattern"
bs-typeahead=
"getColumnNames"
ng-blur=
"render()"
data-min-length=
0
data-items=
100
class=
"input-medium tight-form-input"
>
<input
type=
"text"
ng-model=
"
style
.pattern"
bs-typeahead=
"getColumnNames"
ng-blur=
"render()"
data-min-length=
0
data-items=
100
class=
"input-medium tight-form-input"
>
</li>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
Type
</li>
<li>
<select
class=
"input-small tight-form-input"
ng-model=
"
column
.type"
ng-model=
"
style
.type"
ng-options=
"c.value as c.text for c in columnTypes"
ng-change=
"render()"
style=
"width: 150px"
></select>
</li>
</ul>
<ul
class=
"tight-form-list"
ng-if=
"
column
.type === 'date'"
>
<ul
class=
"tight-form-list"
ng-if=
"
style
.type === 'date'"
>
<li
class=
"tight-form-item"
>
Format
</li>
<li>
<metric-segment-model
property=
"
column
.dateFormat"
options=
"dateFormats"
on-change=
"render()"
custom=
"true"
></metric-segment-model>
<metric-segment-model
property=
"
style
.dateFormat"
options=
"dateFormats"
on-change=
"render()"
custom=
"true"
></metric-segment-model>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form"
ng-if=
"
column
.type === 'number'"
>
<div
class=
"tight-form"
ng-if=
"
style
.type === 'number'"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
Coloring
</li>
<li>
<select
class=
"input-small tight-form-input"
ng-model=
"
column
.colorMode"
ng-model=
"
style
.colorMode"
ng-options=
"c.value as c.text for c in colorModes"
ng-change=
"render()"
style=
"width: 150px"
...
...
@@ -121,34 +121,34 @@
Thresholds
<tip>
Comma seperated values
</tip>
</li>
<li>
<input
type=
"text"
class=
"input-small tight-form-input"
style=
"width: 150px"
ng-model=
"
column
.thresholds"
ng-blur=
"render()"
placeholder=
"0,50,80"
array-join
></input>
<input
type=
"text"
class=
"input-small tight-form-input"
style=
"width: 150px"
ng-model=
"
style
.thresholds"
ng-blur=
"render()"
placeholder=
"0,50,80"
array-join
></input>
</li>
<li
class=
"tight-form-item"
style=
"width: 60px"
>
Colors
</li>
<li
class=
"tight-form-item"
>
<spectrum-picker
ng-model=
"
column
.colors[0]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
column
.colors[1]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
column
.colors[2]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
style
.colors[0]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
style
.colors[1]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
style
.colors[2]"
ng-change=
"render()"
></spectrum-picker>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form"
ng-if=
"
column
.type === 'number'"
>
<div
class=
"tight-form"
ng-if=
"
style
.type === 'number'"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
Unit
</li>
<li
class=
"dropdown"
style=
"width: 150px"
ng-model=
"
column
.unit"
ng-model=
"
style
.unit"
dropdown-typeahead=
"unitFormats"
dropdown-typeahead-on-select=
"setUnitFormat(
column
, $subItem)"
>
dropdown-typeahead-on-select=
"setUnitFormat(
style
, $subItem)"
>
</li>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
Decimals
</li>
<li
style=
"width: 105px"
>
<input
type=
"number"
class=
"input-mini tight-form-input"
ng-model=
"
column
.decimals"
ng-change=
"render()"
ng-model-onblur
>
<input
type=
"number"
class=
"input-mini tight-form-input"
ng-model=
"
style
.decimals"
ng-change=
"render()"
ng-model-onblur
>
</li>
</ul>
<div
class=
"clearfix"
></div>
...
...
@@ -158,7 +158,7 @@
</div>
<button
class=
"btn btn-inverse"
style=
"margin-top: 20px"
ng-click=
"addColumnStyle()"
>
Add
column
display rule
Add
style
display rule
</button>
</div>
public/app/panels/table/editor.ts
View file @
00a479de
...
...
@@ -36,8 +36,8 @@ export function tablePanelEditor() {
{
text
:
'MMMM D, YYYY LT'
,
value
:
'MMMM D, YYYY LT'
},
];
scope
.
update
JsonField
sMenu
=
function
(
data
)
{
scope
.
jsonField
sMenu
=
[];
scope
.
update
Column
sMenu
=
function
(
data
)
{
scope
.
column
sMenu
=
[];
if
(
!
data
||
data
.
length
===
0
)
{
return
;
}
...
...
@@ -58,18 +58,18 @@ export function tablePanelEditor() {
}
_
.
each
(
names
,
function
(
value
,
key
)
{
scope
.
jsonField
sMenu
.
push
({
text
:
key
});
scope
.
column
sMenu
.
push
({
text
:
key
});
});
};
scope
.
update
JsonField
sMenu
(
scope
.
dataRaw
);
scope
.
update
Column
sMenu
(
scope
.
dataRaw
);
scope
.
$on
(
'render'
,
function
(
event
,
table
,
rawData
)
{
scope
.
update
JsonField
sMenu
(
rawData
);
scope
.
update
Column
sMenu
(
rawData
);
});
scope
.
add
JsonField
=
function
(
menuItem
)
{
scope
.
panel
.
field
s
.
push
({
name
:
menuItem
.
text
});
scope
.
add
Column
=
function
(
menuItem
)
{
scope
.
panel
.
column
s
.
push
({
name
:
menuItem
.
text
});
scope
.
render
();
};
...
...
@@ -77,8 +77,8 @@ export function tablePanelEditor() {
scope
.
render
();
};
scope
.
remove
JsonField
=
function
(
field
)
{
scope
.
panel
.
fields
=
_
.
without
(
scope
.
panel
.
fields
,
field
);
scope
.
remove
Column
=
function
(
column
)
{
scope
.
panel
.
column
=
_
.
without
(
scope
.
panel
.
column
,
column
);
scope
.
render
();
};
...
...
@@ -99,11 +99,11 @@ export function tablePanelEditor() {
thresholds
:
[],
};
scope
.
panel
.
column
s
.
push
(
angular
.
copy
(
columnStyleDefaults
));
scope
.
panel
.
style
s
.
push
(
angular
.
copy
(
columnStyleDefaults
));
};
scope
.
removeColumnStyle
=
function
(
col
)
{
scope
.
panel
.
columns
=
_
.
without
(
scope
.
panel
.
columns
,
col
);
scope
.
removeColumnStyle
=
function
(
style
)
{
scope
.
panel
.
styles
=
_
.
without
(
scope
.
panel
.
styles
,
style
);
};
scope
.
getColumnNames
=
function
()
{
...
...
public/app/panels/table/renderer.ts
View file @
00a479de
...
...
@@ -81,8 +81,8 @@ export class TableRenderer {
return
this
.
formaters
[
colIndex
](
value
);
}
for
(
let
i
=
0
;
i
<
this
.
panel
.
column
s
.
length
;
i
++
)
{
let
style
=
this
.
panel
.
column
s
[
i
];
for
(
let
i
=
0
;
i
<
this
.
panel
.
style
s
.
length
;
i
++
)
{
let
style
=
this
.
panel
.
style
s
[
i
];
let
column
=
this
.
table
.
columns
[
colIndex
];
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
if
(
column
.
text
.
match
(
regex
))
{
...
...
public/app/panels/table/specs/renderer_specs.ts
View file @
00a479de
...
...
@@ -15,7 +15,7 @@ describe('when rendering table', () => {
var
panel
=
{
pageSize
:
10
,
column
s
:
[
style
s
:
[
{
pattern
:
'Time'
,
type
:
'date'
,
...
...
public/app/panels/table/specs/transformers_specs.ts
View file @
00a479de
...
...
@@ -71,10 +71,36 @@ describe('when transforming time series table', () => {
});
});
describe
(
'timeseries_to_summaries'
,
()
=>
{
var
panel
=
{
transform
:
'timeseries_to_summaries'
,
sort
:
{
col
:
0
,
desc
:
true
},
};
beforeEach
(()
=>
{
table
=
TableModel
.
transform
(
timeSeries
,
panel
);
});
// it('should return 2 rows', () => {
// expect(table.rows.length).to.be(2);
// expect(table.rows[0][0]).to.be('series1');
// expect(table.rows[0][1]).to.be('Min');
// expect(table.rows[1][0]).to.be('series2');
// });
//
// it('should return 2 columns', () => {
// expect(table.columns.length).to.be(3);
// expect(table.columns[0].text).to.be('Series');
// expect(table.columns[1].text).to.be('Min');
// expect(table.columns[2].text).to.be('Value');
// });
});
describe
(
'JSON Data'
,
()
=>
{
var
panel
=
{
transform
:
'json'
,
field
s
:
[{
name
:
'timestamp'
},
{
name
:
'message'
}]
column
s
:
[{
name
:
'timestamp'
},
{
name
:
'message'
}]
};
var
rawData
=
[
{
...
...
public/app/panels/table/transformers.ts
View file @
00a479de
...
...
@@ -87,8 +87,8 @@ transformers['json'] = {
description
:
'JSON Data'
,
transform
:
function
(
data
,
panel
,
model
)
{
var
i
,
y
,
z
;
for
(
i
=
0
;
i
<
panel
.
field
s
.
length
;
i
++
)
{
model
.
columns
.
push
({
text
:
panel
.
field
s
[
i
].
name
});
for
(
i
=
0
;
i
<
panel
.
column
s
.
length
;
i
++
)
{
model
.
columns
.
push
({
text
:
panel
.
column
s
[
i
].
name
});
}
if
(
model
.
columns
.
length
===
0
)
{
...
...
@@ -101,8 +101,8 @@ transformers['json'] = {
for
(
y
=
0
;
y
<
series
.
datapoints
.
length
;
y
++
)
{
var
dp
=
series
.
datapoints
[
y
];
var
values
=
[];
for
(
z
=
0
;
z
<
panel
.
field
s
.
length
;
z
++
)
{
values
.
push
(
dp
[
panel
.
field
s
[
z
].
name
]);
for
(
z
=
0
;
z
<
panel
.
column
s
.
length
;
z
++
)
{
values
.
push
(
dp
[
panel
.
column
s
[
z
].
name
]);
}
if
(
values
.
length
===
0
)
{
...
...
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