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 {
...
@@ -29,7 +29,7 @@ export class TablePanelCtrl {
transform
:
'timeseries_to_rows'
,
transform
:
'timeseries_to_rows'
,
pageSize
:
50
,
pageSize
:
50
,
showHeader
:
true
,
showHeader
:
true
,
column
s
:
[
style
s
:
[
{
{
type
:
'date'
,
type
:
'date'
,
pattern
:
'Time'
,
pattern
:
'Time'
,
...
@@ -45,13 +45,20 @@ export class TablePanelCtrl {
...
@@ -45,13 +45,20 @@ export class TablePanelCtrl {
thresholds
:
[],
thresholds
:
[],
}
}
],
],
field
s
:
[],
column
s
:
[],
scroll
:
true
,
scroll
:
true
,
fontSize
:
'100%'
,
fontSize
:
'100%'
,
sort
:
{
col
:
0
,
desc
:
true
},
sort
:
{
col
:
0
,
desc
:
true
},
};
};
$scope
.
init
=
function
()
{
$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
);
_
.
defaults
(
$scope
.
panel
,
panelDefaults
);
panelSrv
.
init
(
$scope
);
panelSrv
.
init
(
$scope
);
...
...
public/app/panels/table/editor.html
View file @
00a479de
...
@@ -19,15 +19,15 @@
...
@@ -19,15 +19,15 @@
<div
class=
"tight-form"
ng-if=
"panel.transform === 'json'"
>
<div
class=
"tight-form"
ng-if=
"panel.transform === 'json'"
>
<ul
class=
"tight-form-list"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 140px"
>
<li
class=
"tight-form-item"
style=
"width: 140px"
>
Field
s
Column
s
</li>
</li>
<li
class=
"tight-form-item"
ng-repeat=
"
field in panel.field
s"
>
<li
class=
"tight-form-item"
ng-repeat=
"
column in panel.column
s"
>
<i
class=
"pointer fa fa-remove"
ng-click=
"remove
JsonField(field
)"
></i>
<i
class=
"pointer fa fa-remove"
ng-click=
"remove
Column(column
)"
></i>
<span>
<span>
{{
field
.name}}
{{
column
.name}}
</span>
</span>
</li>
</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>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
@@ -67,11 +67,11 @@
...
@@ -67,11 +67,11 @@
<h5>
Column Styles
</h5>
<h5>
Column Styles
</h5>
<div
class=
"tight-form-container"
>
<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"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list pull-right"
>
<ul
class=
"tight-form-list pull-right"
>
<li
class=
"tight-form-item last"
>
<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>
</li>
</ul>
</ul>
...
@@ -80,38 +80,38 @@
...
@@ -80,38 +80,38 @@
Name or regex
Name or regex
</li>
</li>
<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>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
Type
Type
</li>
</li>
<li>
<li>
<select
class=
"input-small tight-form-input"
<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-options=
"c.value as c.text for c in columnTypes"
ng-change=
"render()"
ng-change=
"render()"
style=
"width: 150px"
style=
"width: 150px"
></select>
></select>
</li>
</li>
</ul>
</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"
>
<li
class=
"tight-form-item"
>
Format
Format
</li>
</li>
<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>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</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"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
Coloring
Coloring
</li>
</li>
<li>
<li>
<select
class=
"input-small tight-form-input"
<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-options=
"c.value as c.text for c in colorModes"
ng-change=
"render()"
ng-change=
"render()"
style=
"width: 150px"
style=
"width: 150px"
...
@@ -121,34 +121,34 @@
...
@@ -121,34 +121,34 @@
Thresholds
<tip>
Comma seperated values
</tip>
Thresholds
<tip>
Comma seperated values
</tip>
</li>
</li>
<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>
<li
class=
"tight-form-item"
style=
"width: 60px"
>
<li
class=
"tight-form-item"
style=
"width: 60px"
>
Colors
Colors
</li>
</li>
<li
class=
"tight-form-item"
>
<li
class=
"tight-form-item"
>
<spectrum-picker
ng-model=
"
column
.colors[0]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
style
.colors[0]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
column
.colors[1]"
ng-change=
"render()"
></spectrum-picker>
<spectrum-picker
ng-model=
"
style
.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[2]"
ng-change=
"render()"
></spectrum-picker>
</li>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</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"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
<li
class=
"tight-form-item text-right"
style=
"width: 93px"
>
Unit
Unit
</li>
</li>
<li
class=
"dropdown"
style=
"width: 150px"
<li
class=
"dropdown"
style=
"width: 150px"
ng-model=
"
column
.unit"
ng-model=
"
style
.unit"
dropdown-typeahead=
"unitFormats"
dropdown-typeahead=
"unitFormats"
dropdown-typeahead-on-select=
"setUnitFormat(
column
, $subItem)"
>
dropdown-typeahead-on-select=
"setUnitFormat(
style
, $subItem)"
>
</li>
</li>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
<li
class=
"tight-form-item"
style=
"width: 86px"
>
Decimals
Decimals
</li>
</li>
<li
style=
"width: 105px"
>
<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>
</li>
</ul>
</ul>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
...
@@ -158,7 +158,7 @@
...
@@ -158,7 +158,7 @@
</div>
</div>
<button
class=
"btn btn-inverse"
style=
"margin-top: 20px"
ng-click=
"addColumnStyle()"
>
<button
class=
"btn btn-inverse"
style=
"margin-top: 20px"
ng-click=
"addColumnStyle()"
>
Add
column
display rule
Add
style
display rule
</button>
</button>
</div>
</div>
public/app/panels/table/editor.ts
View file @
00a479de
...
@@ -36,8 +36,8 @@ export function tablePanelEditor() {
...
@@ -36,8 +36,8 @@ export function tablePanelEditor() {
{
text
:
'MMMM D, YYYY LT'
,
value
:
'MMMM D, YYYY LT'
},
{
text
:
'MMMM D, YYYY LT'
,
value
:
'MMMM D, YYYY LT'
},
];
];
scope
.
update
JsonField
sMenu
=
function
(
data
)
{
scope
.
update
Column
sMenu
=
function
(
data
)
{
scope
.
jsonField
sMenu
=
[];
scope
.
column
sMenu
=
[];
if
(
!
data
||
data
.
length
===
0
)
{
if
(
!
data
||
data
.
length
===
0
)
{
return
;
return
;
}
}
...
@@ -58,18 +58,18 @@ export function tablePanelEditor() {
...
@@ -58,18 +58,18 @@ export function tablePanelEditor() {
}
}
_
.
each
(
names
,
function
(
value
,
key
)
{
_
.
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
.
$on
(
'render'
,
function
(
event
,
table
,
rawData
)
{
scope
.
update
JsonField
sMenu
(
rawData
);
scope
.
update
Column
sMenu
(
rawData
);
});
});
scope
.
add
JsonField
=
function
(
menuItem
)
{
scope
.
add
Column
=
function
(
menuItem
)
{
scope
.
panel
.
field
s
.
push
({
name
:
menuItem
.
text
});
scope
.
panel
.
column
s
.
push
({
name
:
menuItem
.
text
});
scope
.
render
();
scope
.
render
();
};
};
...
@@ -77,8 +77,8 @@ export function tablePanelEditor() {
...
@@ -77,8 +77,8 @@ export function tablePanelEditor() {
scope
.
render
();
scope
.
render
();
};
};
scope
.
remove
JsonField
=
function
(
field
)
{
scope
.
remove
Column
=
function
(
column
)
{
scope
.
panel
.
fields
=
_
.
without
(
scope
.
panel
.
fields
,
field
);
scope
.
panel
.
column
=
_
.
without
(
scope
.
panel
.
column
,
column
);
scope
.
render
();
scope
.
render
();
};
};
...
@@ -99,11 +99,11 @@ export function tablePanelEditor() {
...
@@ -99,11 +99,11 @@ export function tablePanelEditor() {
thresholds
:
[],
thresholds
:
[],
};
};
scope
.
panel
.
column
s
.
push
(
angular
.
copy
(
columnStyleDefaults
));
scope
.
panel
.
style
s
.
push
(
angular
.
copy
(
columnStyleDefaults
));
};
};
scope
.
removeColumnStyle
=
function
(
col
)
{
scope
.
removeColumnStyle
=
function
(
style
)
{
scope
.
panel
.
columns
=
_
.
without
(
scope
.
panel
.
columns
,
col
);
scope
.
panel
.
styles
=
_
.
without
(
scope
.
panel
.
styles
,
style
);
};
};
scope
.
getColumnNames
=
function
()
{
scope
.
getColumnNames
=
function
()
{
...
...
public/app/panels/table/renderer.ts
View file @
00a479de
...
@@ -81,8 +81,8 @@ export class TableRenderer {
...
@@ -81,8 +81,8 @@ export class TableRenderer {
return
this
.
formaters
[
colIndex
](
value
);
return
this
.
formaters
[
colIndex
](
value
);
}
}
for
(
let
i
=
0
;
i
<
this
.
panel
.
column
s
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
panel
.
style
s
.
length
;
i
++
)
{
let
style
=
this
.
panel
.
column
s
[
i
];
let
style
=
this
.
panel
.
style
s
[
i
];
let
column
=
this
.
table
.
columns
[
colIndex
];
let
column
=
this
.
table
.
columns
[
colIndex
];
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
var
regex
=
kbn
.
stringToJsRegex
(
style
.
pattern
);
if
(
column
.
text
.
match
(
regex
))
{
if
(
column
.
text
.
match
(
regex
))
{
...
...
public/app/panels/table/specs/renderer_specs.ts
View file @
00a479de
...
@@ -15,7 +15,7 @@ describe('when rendering table', () => {
...
@@ -15,7 +15,7 @@ describe('when rendering table', () => {
var
panel
=
{
var
panel
=
{
pageSize
:
10
,
pageSize
:
10
,
column
s
:
[
style
s
:
[
{
{
pattern
:
'Time'
,
pattern
:
'Time'
,
type
:
'date'
,
type
:
'date'
,
...
...
public/app/panels/table/specs/transformers_specs.ts
View file @
00a479de
...
@@ -71,10 +71,36 @@ describe('when transforming time series table', () => {
...
@@ -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'
,
()
=>
{
describe
(
'JSON Data'
,
()
=>
{
var
panel
=
{
var
panel
=
{
transform
:
'json'
,
transform
:
'json'
,
field
s
:
[{
name
:
'timestamp'
},
{
name
:
'message'
}]
column
s
:
[{
name
:
'timestamp'
},
{
name
:
'message'
}]
};
};
var
rawData
=
[
var
rawData
=
[
{
{
...
...
public/app/panels/table/transformers.ts
View file @
00a479de
...
@@ -87,8 +87,8 @@ transformers['json'] = {
...
@@ -87,8 +87,8 @@ transformers['json'] = {
description
:
'JSON Data'
,
description
:
'JSON Data'
,
transform
:
function
(
data
,
panel
,
model
)
{
transform
:
function
(
data
,
panel
,
model
)
{
var
i
,
y
,
z
;
var
i
,
y
,
z
;
for
(
i
=
0
;
i
<
panel
.
field
s
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
panel
.
column
s
.
length
;
i
++
)
{
model
.
columns
.
push
({
text
:
panel
.
field
s
[
i
].
name
});
model
.
columns
.
push
({
text
:
panel
.
column
s
[
i
].
name
});
}
}
if
(
model
.
columns
.
length
===
0
)
{
if
(
model
.
columns
.
length
===
0
)
{
...
@@ -101,8 +101,8 @@ transformers['json'] = {
...
@@ -101,8 +101,8 @@ transformers['json'] = {
for
(
y
=
0
;
y
<
series
.
datapoints
.
length
;
y
++
)
{
for
(
y
=
0
;
y
<
series
.
datapoints
.
length
;
y
++
)
{
var
dp
=
series
.
datapoints
[
y
];
var
dp
=
series
.
datapoints
[
y
];
var
values
=
[];
var
values
=
[];
for
(
z
=
0
;
z
<
panel
.
field
s
.
length
;
z
++
)
{
for
(
z
=
0
;
z
<
panel
.
column
s
.
length
;
z
++
)
{
values
.
push
(
dp
[
panel
.
field
s
[
z
].
name
]);
values
.
push
(
dp
[
panel
.
column
s
[
z
].
name
]);
}
}
if
(
values
.
length
===
0
)
{
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